public ActionResult AssignPositionAdd(AssignPositionActionView model) { try { HttpCookie reqCookies = Request.Cookies["StaffLoginCookie"]; ResponseStaffLogin login = JsonConvert.DeserializeObject <ResponseStaffLogin>(reqCookies.Value.ToString().UrlDecode()); if (ModelState.IsValid) { model.ActionBy = login.Account; if (_assignPosition.Add(model)) { _assignPosition.Save(); return(Redirect("/Staff/AssignPosition")); } } ViewBag.PositionList = _positionBusiness.GetAll(); ViewBag.StaffList = _staffBusiness.GetAll(); ViewBag.DepartmentList = _departmentBusiness.GetAll(); return(View(model)); } catch (Exception) { ViewBag.PositionList = _positionBusiness.GetAll(); ViewBag.StaffList = _staffBusiness.GetAll(); ViewBag.DepartmentList = _departmentBusiness.GetAll(); return(View(model)); } }
public bool Add(AssignPositionActionView model) { try { AssignPosition assignPosition = new AssignPosition(); assignPosition.CreateBy = model.ActionBy; assignPosition.CreateDate = DateTime.Now; assignPosition.DepartmentID = model.DepartmentID; assignPosition.Desc = model.Desc; assignPosition.ModifyBy = model.ActionBy; assignPosition.ModifyDate = DateTime.Now; assignPosition.PositionID = model.PositionID; assignPosition.StaffID = model.StaffID; assignPosition.Status = model.Status; DbContext.AssignPositions.Add(assignPosition); return(true); } catch (System.Exception) { return(false); } }
public bool Add(AssignPositionActionView model) { return(_assignPosition.Add(model)); }