public Status UpdateStaff(int conditionuserid, string staffname, string telephone, string image, string position) { this._logger.LogWarning("The server execute UpdateStaff Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TStaff staff = new TStaff() { StaffName = staffname, Telephone = telephone, Image = image, Position = position, }; var ReadPeoples = dbcontext.TStaff.Where(a => true).ToList().Find(a => a.Id == conditionuserid); ReadPeoples.StaffName = staff.StaffName; ReadPeoples.Telephone = staff.Telephone; ReadPeoples.Image = staff.Image; ReadPeoples.Position = staff.Position; 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 UpdateStaff Fuction --" + ex.Message + DateTime.Now.ToString()); Status status = new Status() { StatusCode = 0, Message = "修改失败", ReturnTime = DateTime.Now }; return(status); } } }
public Status UpdateStorage(string conditionuserproductinfo, string productinfo, float price, DateTime storagetime, string remark) { this._logger.LogWarning("The server execute UpdateStorage Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TStorage storage = new TStorage() { ProductInfo = productinfo, Price = price, StorageTime = storagetime, Remark = remark, }; var ReadPeoples = dbcontext.TStorage.Where(a => true).ToList().Find(a => a.ProductInfo == conditionuserproductinfo); ReadPeoples.ProductInfo = storage.ProductInfo; ReadPeoples.Price = storage.Price; ReadPeoples.StorageTime = storage.StorageTime; ReadPeoples.Remark = storage.Remark; 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 UpdateStorage Fuction --" + ex.Message + DateTime.Now.ToString()); Status status = new Status() { StatusCode = 0, Message = "修改失败", ReturnTime = DateTime.Now }; return(status); } } }
public Status UpdateBill(int id, float price, DateTime BillDatetime, string conductor, string remark) { this._logger.LogWarning("The server execute UpdateBill Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TBill bill = new TBill() { Price = price, BillDatetime = BillDatetime, Conductor = conductor, Remark = remark, }; var ReadPeoples = dbcontext.TBill.Where(a => true).ToList().Find(a => a.Id == id); ReadPeoples.Price = bill.Price; ReadPeoples.BillDatetime = bill.BillDatetime; ReadPeoples.Conductor = bill.Conductor; ReadPeoples.Remark = bill.Remark; 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 UpdateBill 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); } } }
/// <summary> /// 添加一条记录 /// </summary> /// <param name="t"></param> /// <returns></returns> public int Add(T t) { dbContent.Entry <T>(t).State = EntityState.Added; return(dbContent.SaveChanges()); }