using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BLL { /// /// 天气记录 /// public class WeatherService { public static Model.SGGLDB db = Funs.DB; /// /// 根据主键获取事故类型 /// /// /// public static Model.Weather GetWeatherByDateAndCity(DateTime date, string city) { return Funs.DB.Weather.FirstOrDefault(e => e.Date == date && e.City == city); } /// /// 添加事故类型 /// /// public static void AddWeather(Model.Weather weather) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { Model.Weather newWeather = new Model.Weather { WeatherId = weather.WeatherId, City = weather.City, Date = weather.Date, WeatherRef = weather.WeatherRef, CurrTem = weather.CurrTem, AllTem = weather.AllTem }; db.Weather.InsertOnSubmit(newWeather); db.SubmitChanges(); } } /// /// 根据主键删除事故类型 /// /// public static void DeleteWeatherById(string weatherId) { Model.SGGLDB db = Funs.DB; Model.Weather weather = db.Weather.FirstOrDefault(e => e.WeatherId == weatherId); if (weather != null) { db.Weather.DeleteOnSubmit(weather); db.SubmitChanges(); } } } }