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 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 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); } } }