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 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);
                }
            }
        }
 private void DeleteStaff(TStaff staff)
 {
     _realm.Write(() => _realm.Remove(staff));
 }