public ActionResult Edit(BonusDisciplineViewModel model) { if (ModelState.IsValid) { if (Request["Submit"] == "Save") { var BonusDiscipline = BonusDisciplineRepository.GetBonusDisciplineById(model.Id); AutoMapper.Mapper.Map(model, BonusDiscipline); BonusDiscipline.ModifiedUserId = WebSecurity.CurrentUserId; BonusDiscipline.ModifiedDate = DateTime.Now; var prefixBonus = Erp.BackOffice.Helpers.Common.GetSetting("prefixOrderNo_Bonus"); var prefixDiscipline = Erp.BackOffice.Helpers.Common.GetSetting("prefixOrderNo_Discipline"); if (BonusDiscipline.Category == "Bonus") { BonusDiscipline.Code = Erp.BackOffice.Helpers.Common.GetCode(prefixBonus, model.Id); } else { BonusDiscipline.Code = Erp.BackOffice.Helpers.Common.GetCode(prefixDiscipline, model.Id); } BonusDisciplineRepository.UpdateBonusDiscipline(BonusDiscipline); TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess + " " + BonusDiscipline.Code; if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True") { ViewBag.closePopup = "true"; model.CategoryList = Helpers.SelectListHelper.GetSelectList_Category("BonusDiscipline_Category", null, "Value", App_GlobalResources.Wording.Empty); var user = userRepository.GetUserById(WebSecurity.CurrentUserId); var staff = Erp.BackOffice.Helpers.Common.GetStaffByCurrentUser(); model.DepartmentList = Helpers.SelectListHelper.GetSelectList_BranchDepartment(model.PlaceDecisions, model.PlaceDecisions_Branch.Value, App_GlobalResources.Wording.Empty); model.BranchList = Helpers.SelectListHelper.GetSelectList_Branch(model.PlaceDecisions_Branch, App_GlobalResources.Wording.Empty); if (model.Category == "Bonus") { model.ReasonList = Helpers.SelectListHelper.GetSelectList_Category("Reason_Bonus", model.Reason, "Value", App_GlobalResources.Wording.Empty); model.FormalityList = Helpers.SelectListHelper.GetSelectList_Category("Formality_Bonus", model.Formality, "Value", App_GlobalResources.Wording.Empty); } else { model.ReasonList = Helpers.SelectListHelper.GetSelectList_Category("Reason_Discipline", model.Reason, "Value", App_GlobalResources.Wording.Empty); model.FormalityList = Helpers.SelectListHelper.GetSelectList_Category("Formality_Discipline", model.Formality, "Value", App_GlobalResources.Wording.Empty); } ViewBag.user = user.UserTypeId; return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" })); // return View(model); } return(RedirectToAction("Index")); } } TempData[Globals.FailedMessageKey] = App_GlobalResources.Error.UpdateUnsuccess + " " + model.Code; return(RedirectToAction("Index")); }
public ActionResult Detail(int?Id) { var bonusDiscipline = BonusDisciplineRepository.GetvwBonusDisciplineById(Id.Value); if (bonusDiscipline != null && bonusDiscipline.IsDeleted != true) { var model = new BonusDisciplineViewModel(); AutoMapper.Mapper.Map(bonusDiscipline, model); return(View(model)); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(RedirectToAction("Index")); }
/// <summary> /// /// </summary> /// <param name="Id">StaffId</param> /// <returns></returns> public ViewResult Create(int?Id) { var model = new BonusDisciplineViewModel(); if (Id != null && Id.Value > 0) { model.StaffId = Id; var staffs = staffsRepository.GetStaffsById(Id.Value); model.Name = staffs.Name; } //model.StaffList = Helpers.SelectListHelper.GetSelectList_Staff(null); //model.CategoryList = Helpers.SelectListHelper.GetSelectList_Category("BonusDiscipline_Category", null, "Value", App_GlobalResources.Wording.Empty); var user = userRepository.GetUserById(WebSecurity.CurrentUserId); var staff = Erp.BackOffice.Helpers.Common.GetStaffByCurrentUser(); // model.DepartmentList = Helpers.SelectListHelper.GetSelectList_BranchDepartment(null, staff.Sale_BranchId.HasValue?staff.Sale_BranchId.Value:0,App_GlobalResources.Wording.Empty); //model.BranchList = Helpers.SelectListHelper.GetSelectList_Branch(null); ViewBag.user = user.UserTypeId; return(View(model)); }
public ActionResult Edit(int?Id) { var BonusDiscipline = BonusDisciplineRepository.GetvwBonusDisciplineById(Id.Value); if (BonusDiscipline != null && BonusDiscipline.IsDeleted != true) { var model = new BonusDisciplineViewModel(); AutoMapper.Mapper.Map(BonusDiscipline, model); // model.StaffList = Helpers.SelectListHelper.GetSelectList_Staff(); model.CategoryList = Helpers.SelectListHelper.GetSelectList_Category("BonusDiscipline_Category", null, "Value", App_GlobalResources.Wording.Empty); var user = userRepository.GetUserById(WebSecurity.CurrentUserId); var staff = Erp.BackOffice.Helpers.Common.GetStaffByCurrentUser(); model.DepartmentList = Helpers.SelectListHelper.GetSelectList_BranchDepartment(model.PlaceDecisions, model.PlaceDecisions_Branch.Value, App_GlobalResources.Wording.Empty); model.BranchList = Helpers.SelectListHelper.GetSelectList_Branch(model.PlaceDecisions_Branch, App_GlobalResources.Wording.Empty); if (model.Category == "Bonus") { model.ReasonList = Helpers.SelectListHelper.GetSelectList_Category("Reason_Bonus", model.Reason, "Value", App_GlobalResources.Wording.Empty); model.FormalityList = Helpers.SelectListHelper.GetSelectList_Category("Formality_Bonus", model.Formality, "Value", App_GlobalResources.Wording.Empty); } else { model.ReasonList = Helpers.SelectListHelper.GetSelectList_Category("Reason_Discipline", model.Reason, "Value", App_GlobalResources.Wording.Empty); model.FormalityList = Helpers.SelectListHelper.GetSelectList_Category("Formality_Discipline", model.Formality, "Value", App_GlobalResources.Wording.Empty); } ViewBag.user = user.UserTypeId; //if (model.CreatedUserId != Erp.BackOffice.Helpers.Common.CurrentUser.Id && Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId != 1) //{ // TempData["FailedMessage"] = "NotOwner"; // return RedirectToAction("Index"); //} return(View(model)); } if (Request.UrlReferrer != null) { return(Redirect(Request.UrlReferrer.AbsoluteUri)); } return(RedirectToAction("Index")); }
public ActionResult Create(BonusDisciplineViewModel model) { var urlRefer = Request["UrlReferrer"]; if (ModelState.IsValid) { var user = userRepository.GetUserById(WebSecurity.CurrentUserId); var BonusDiscipline = new Domain.Staff.Entities.BonusDiscipline(); AutoMapper.Mapper.Map(model, BonusDiscipline); BonusDiscipline.IsDeleted = false; BonusDiscipline.CreatedUserId = WebSecurity.CurrentUserId; BonusDiscipline.ModifiedUserId = WebSecurity.CurrentUserId; BonusDiscipline.CreatedDate = DateTime.Now; BonusDiscipline.ModifiedDate = DateTime.Now; BonusDiscipline.DayDecision = DateTime.Now; BonusDisciplineRepository.InsertBonusDiscipline(BonusDiscipline); var prefixBonus = Erp.BackOffice.Helpers.Common.GetSetting("prefixOrderNo_Bonus"); var prefixDiscipline = Erp.BackOffice.Helpers.Common.GetSetting("prefixOrderNo_Discipline"); if (BonusDiscipline.Category == "Bonus") { BonusDiscipline.Code = Erp.BackOffice.Helpers.Common.GetCode(prefixBonus, BonusDiscipline.Id); BonusDisciplineRepository.UpdateBonusDiscipline(BonusDiscipline); } else { BonusDiscipline.Code = Erp.BackOffice.Helpers.Common.GetCode(prefixDiscipline, BonusDiscipline.Id); BonusDisciplineRepository.UpdateBonusDiscipline(BonusDiscipline); } TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess + " " + BonusDiscipline.Code; if (Request["IsPopup"] == "true") { return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" })); } return(Redirect(urlRefer)); } TempData[Globals.FailedMessageKey] = App_GlobalResources.Error.InsertUnsucess; return(RedirectToAction("Index")); }