public Status DeleteStaff(int id) { this._logger.LogWarning("The server execute DeleteStaff Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { try { var a = dbcontext.TStaff.Where(a => true).ToList().Find(a => a.Id == id); dbcontext.TStaff.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 DeleteStaff Fuction --" + ex.Message + DateTime.Now.ToString()); Status status = new Status() { StatusCode = 0, Message = "删除失败", ReturnTime = DateTime.Now }; return(status); } } }
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 DeleteStorage(string productinfo) { this._logger.LogWarning("The server execute DeleteStorage Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TStorage userInfo = new TStorage() { ProductInfo = productinfo }; try { var a = dbcontext.TStorage.Where(a => true).ToList().Find(a => a.ProductInfo == productinfo); dbcontext.TStorage.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 DeleteStorage Fuction --" + ex.Message + DateTime.Now.ToString()); Status status = new Status() { StatusCode = 0, Message = "删除失败", ReturnTime = DateTime.Now }; return(status); } } }
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); } } }
public Status AddStorage(string productinfo, float price, DateTime storagetime, string remark) { this._logger.LogWarning("The server execute AddStorage Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TStorage storage = new TStorage() { ProductInfo = productinfo, Price = price, StorageTime = storagetime, Remark = remark, }; try { dbcontext.Add(storage); dbcontext.SaveChanges(); Status status = new Status() { StatusCode = 200, Message = "添加成功", ReturnTime = DateTime.Now }; return(status); } catch (Exception ex) { this._logger.LogWarning("The server execute AddStorage Fuction --" + ex.Message + DateTime.Now.ToString()); Status status = new Status() { StatusCode = 0, Message = "添加失败", ReturnTime = DateTime.Now }; return(status); } } }
public Status AddBill(float price, DateTime BillDatetime, string conductor, string remark) { this._logger.LogWarning("The server execute AddBill Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TBill bill = new TBill() { Price = price, BillDatetime = BillDatetime, Conductor = conductor, Remark = remark, }; try { dbcontext.Add(bill); dbcontext.SaveChanges(); Status status = new Status() { StatusCode = 200, Message = "添加成功", ReturnTime = DateTime.Now }; return(status); } catch (Exception ex) { this._logger.LogWarning("The server execute AddBill 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); } } }
public Status AddStaff(string staffname, string telephone, string position, List <IFormFile> files) { List <string> filenames = new List <string>(); string resultfilename = string.Empty; bool flag; this._logger.LogWarning("The server execute AddStaff Fuction --" + DateTime.Now.ToString()); using (SchoolCookHouseContext dbcontext = new SchoolCookHouseContext()) { TStaff staff = new TStaff() { StaffName = staffname, Telephone = telephone, Position = position, }; if (staffname != "") { flag = UpLoadFile.FileSave(files, staffname, out filenames); } else { flag = UpLoadFile.FileSave(files, DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), out filenames); } try { if (flag) { filenames.Sort(); resultfilename = string.Join("", filenames.ToArray()); staff.Image = resultfilename; dbcontext.Add(staff); dbcontext.SaveChanges(); Status status = new Status() { StatusCode = 200, Message = "添加成功", ReturnTime = DateTime.Now }; return(status); } else { Status status = new Status() { StatusCode = 0, Message = "添加失败", ReturnTime = DateTime.Now }; return(status); } } catch (Exception ex) { this._logger.LogWarning("The server execute AddStaff 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()); }