public bool Update(int?Id, StaffParam staffParam) { var result = 0; var staff = Get(Id); staff.FirstName = staffParam.FirstName; staff.LastName = staffParam.LastName; staff.Dob = staffParam.Dob; staff.Pob = staffParam.Pob; staff.Gender = staffParam.Gender; staff.Religions = myContext.Religions.Find(staffParam.Religions); staff.Villages = myContext.Villages.Find(staffParam.Villages); staff.Address = staffParam.Address; staff.Phone = staffParam.Phone; staff.Email = staffParam.Email; staff.Username = staffParam.Username; staff.Password = staffParam.Password; staff.Roles = myContext.Roles.Find(staffParam.Roles); staff.SecretQuestion = staffParam.SecretQuestion; staff.SecretAnswer = staffParam.SecretAnswer; staff.Picture = staffParam.Picture; staff.UpdateDate = DateTimeOffset.UtcNow.LocalDateTime; result = myContext.SaveChanges(); if (result > 0) { status = true; } return(status); }
public ActionResult ParamsEdit([Bind(Include = "Id,Name,Value,StaffParamOrder,IsDefault,StaffParamTypeId")] StaffParam staffParam) { if (ModelState.IsValid) { if (staffParam.IsDefault == true) { //找到旧的默认值,改为false(如果有的话) var oldStaffParam = db.StaffParams.Where(p => p.StaffParamTypeId == staffParam.StaffParamTypeId && p.IsDefault == true).ToList(); if (oldStaffParam.Count == 1) { oldStaffParam[0].IsDefault = false; db.Entry(oldStaffParam[0]).State = EntityState.Modified; db.SaveChanges(); } } StaffParam param = db.StaffParams.Find(staffParam.Id); param.ChangePerson = this.Name; param.ChangeTime = DateTime.Now; param.Value = staffParam.Value; param.StaffParamTypeId = staffParam.StaffParamTypeId; param.StaffParamOrder = staffParam.StaffParamOrder; param.IsDefault = staffParam.IsDefault; db.Entry(param).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ParamsIndex", new { id = staffParam.StaffParamTypeId })); } ViewBag.StaffParamTypeId = new SelectList(db.StaffParamTypes, "Id", "Name", staffParam.StaffParamTypeId); return(View(staffParam)); }
public ActionResult ParamsCreate(StaffParam staffParam) { if (ModelState.IsValid) { if (staffParam.IsDefault == true) { //找到旧的默认值,改为false(如果有的话) var oldStaffParam = db.StaffParams.Where(p => p.StaffParamTypeId == staffParam.StaffParamTypeId && p.IsDefault == true).ToList(); if (oldStaffParam.Count == 1) { oldStaffParam[0].IsDefault = false; db.Entry(oldStaffParam[0]).State = EntityState.Modified; db.SaveChanges(); } } staffParam.Extra = "0"; staffParam.RecordPerson = this.Name; staffParam.RecordTime = DateTime.Now; staffParam.StaffParamOrder = 99; db.StaffParams.Add(staffParam); db.SaveChanges(); return(RedirectToAction("ParamsIndex", new { id = staffParam.StaffParamTypeId })); } ViewBag.TypeId = staffParam.StaffParamTypeId; return(View(staffParam)); }
public ActionResult DeleteConfirmed(int id) { StaffParam staffParam = db.StaffParams.Find(id); db.StaffParams.Remove(staffParam); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool Update(int?Id, StaffParam staffParam) { if (Id != null && staffParam != null) { status = _staffRepository.Update(Id, staffParam); } return(status); }
public bool Insert(StaffParam staffParam) { if (staffParam != null) { status = _staffRepository.Insert(staffParam); } return(status); }
public ActionResult ParamsDeleteConfirmed(int id) { StaffParam staffParam = db.StaffParams.Find(id); db.StaffParams.Remove(staffParam); db.SaveChanges(); return(RedirectToAction("ParamsIndex", new { id = staffParam.StaffParamTypeId })); }
public ActionResult Edit([Bind(Include = "Id,Name,Value,StaffParamTypeId")] StaffParam staffParam) { if (ModelState.IsValid) { db.Entry(staffParam).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StaffParamTypeId = new SelectList(db.StaffParamTypes, "Id", "Name", staffParam.StaffParamTypeId); return(View(staffParam)); }
public ActionResult Create([Bind(Include = "Id,Name,Value,StaffParamTypeId")] StaffParam staffParam) { if (ModelState.IsValid) { staffParam.Extra = "0"; db.StaffParams.Add(staffParam); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StaffParamTypeId = new SelectList(db.StaffParamTypes, "Id", "Name", staffParam.StaffParamTypeId); return(View(staffParam)); }
// GET: StaffParams/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffParam staffParam = db.StaffParams.Find(id); if (staffParam == null) { return(HttpNotFound()); } return(View(staffParam)); }
// GET: StaffParams/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StaffParam staffParam = db.StaffParams.Find(id); if (staffParam == null) { return(HttpNotFound()); } ViewBag.StaffParamTypeId = new SelectList(db.StaffParamTypes, "Id", "Name", staffParam.StaffParamTypeId); return(View(staffParam)); }
public ActionResult Edit([Bind(Include = "Id,Name,Value,StaffParamTypeId")] StaffParam staffParam) { if (ModelState.IsValid) { StaffParam param = db.StaffParams.Find(staffParam.Id); param.ChangePerson = this.Name; param.ChangeTime = DateTime.Now; param.Value = staffParam.Value; param.StaffParamTypeId = staffParam.StaffParamTypeId; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StaffParamTypeId = new SelectList(db.StaffParamTypes, "Id", "Name", staffParam.StaffParamTypeId); return(View(staffParam)); }
public ActionResult Manage(string Profile, string Len, string Photo, string Leave, int Period, string PeriodDays) { StaffParam tmpStaffParams = db.StaffParams.Where(p => p.Id == Period).Single(); tmpStaffParams.Extra = PeriodDays; db.Entry(tmpStaffParams).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); StaffBasicParam[] list = db.StaffBasicParams.ToArray(); list[1].Value = Profile; list[2].Value = Len; list[3].Value = Photo; list[4].Value = Leave; db.Entry(list[1]).State = System.Data.Entity.EntityState.Modified; db.Entry(list[2]).State = System.Data.Entity.EntityState.Modified; db.Entry(list[3]).State = System.Data.Entity.EntityState.Modified; db.Entry(list[4]).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Manage")); }
// PUT: api/Priorities/5 public void Put(int id, StaffParam staffParam) { _staffService.Update(id, staffParam); }
// POST: api/Priorities public void Post(StaffParam staffParam) { _staffService.Insert(staffParam); }