public Status DeleteCookHouseInfo(string cookhousename) { this._logger.LogWarning("The server execute DeleteCookHouseInfo Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TCookHouseInfo userInfo = new TCookHouseInfo() { CookHouseName = cookhousename }; try { var a = dbcontext.TCookHouseInfo.Where(a => true).ToList().Find(a => a.CookHouseName == cookhousename); dbcontext.TCookHouseInfo.Remove(a); dbcontext.SaveChanges(); Status status = new Status() { StatusCode = 200, Message = "删除成功", ReturnTime = DateTime.Now }; return(status); } catch (Exception ex) { this._logger.LogWarning("The server execute DeleteCookHouseInfo Fuction --" + ex.Message + DateTime.Now.ToString()); Status status = new Status() { StatusCode = 0, Message = "删除失败", ReturnTime = DateTime.Now }; return(status); } } }
public Status UpdateCookHouseInfo(string conditionusercookhousename, string cookhousename, float temperature, float humidity, string reporttime) { this._logger.LogWarning("The server execute UpdateCookHouseInfo Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TCookHouseInfo cookHouseInfo = new TCookHouseInfo() { CookHouseName = cookhousename, Temperature = temperature, Humidity = humidity, ReportTime = reporttime, }; var ReadPeoples = dbcontext.TCookHouseInfo.Where(a => true).ToList().Find(a => a.CookHouseName == conditionusercookhousename); ReadPeoples.CookHouseName = cookHouseInfo.CookHouseName; ReadPeoples.Temperature = cookHouseInfo.Temperature; ReadPeoples.Humidity = cookHouseInfo.Humidity; ReadPeoples.ReportTime = cookHouseInfo.ReportTime; try { dbcontext.Entry(ReadPeoples).State = EntityState.Modified; dbcontext.SaveChanges(); Status status = new Status() { StatusCode = 200, Message = "修改成功", ReturnTime = DateTime.Now }; return(status); } catch (Exception ex) { this._logger.LogWarning("The server execute UpdateCookHouseInfo Fuction --" + ex.Message + DateTime.Now.ToString()); Status status = new Status() { StatusCode = 0, Message = "修改失败", ReturnTime = DateTime.Now }; return(status); } } }
public Status AddCookHouseInfo(string cookhousename, float temperature, float humidity, string reporttime) { this._logger.LogWarning("The server execute AddCookHouseInfo Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TCookHouseInfo cookHouseInfo = new TCookHouseInfo() { CookHouseName = cookhousename, Temperature = temperature, Humidity = humidity, ReportTime = reporttime, }; try { dbcontext.Add(cookHouseInfo); dbcontext.SaveChanges(); Status status = new Status() { StatusCode = 200, Message = "添加成功", ReturnTime = DateTime.Now }; return(status); } catch (Exception ex) { this._logger.LogWarning("The server execute AddCookHouseInfo Fuction --" + ex.Message + DateTime.Now.ToString()); Status status = new Status() { StatusCode = 0, Message = "添加失败", ReturnTime = DateTime.Now }; return(status); } } }