public ActionResult Edit(int id) { if (CurrentUser.UserRole == Enums.UserRole.Viewer || CurrentUser.UserRole == Enums.UserRole.Controller) { return(RedirectToAction("Detail", new { id })); } var model = new PoaDelegationFormViewModel(); try { model = Mapper.Map <PoaDelegationFormViewModel>(_poaDelegationBll.GetById(id)); model = SetListModel(model, false); model.ChangesHistoryList = Mapper.Map <List <ChangesHistoryItemModel> >( _changesHistoryBll.GetByFormTypeAndFormId(Enums.MenuList.PoaDelegation, id.ToString())); } catch (Exception ex) { AddMessageInfo(ex.Message, Enums.MessageInfoType.Error); model = SetListModel(model, false); } return(View("Edit", model)); }
public ActionResult Create() { if (CurrentUser.UserRole == Enums.UserRole.Viewer || CurrentUser.UserRole == Enums.UserRole.Controller) { AddMessageInfo("Operation not allow", Enums.MessageInfoType.Error); return(RedirectToAction("Index")); } var model = new PoaDelegationFormViewModel(); model = SetListModel(model, true); return(View("Create", model)); }
private POA_DELEGATIONDto SavePoaDelegationToDatabase(PoaDelegationFormViewModel model) { var dataToSave = Mapper.Map <POA_DELEGATIONDto>(model); var input = new PoaDelegationSaveInput() { PoaDelegationDto = dataToSave, UserId = CurrentUser.USER_ID, UserRole = CurrentUser.UserRole, }; return(_poaDelegationBll.SavePoaDelegation(input)); }
private PoaDelegationFormViewModel SetListModel(PoaDelegationFormViewModel model, bool isCreateView) { model.MainMenu = Enums.MenuList.MasterData; model.CurrentMenu = PageInfo; if (isCreateView) { var listUsers = _userBll.GetUsers(); var selectList = from s in listUsers select new SelectListItem { Value = s.USER_ID, Text = s.USER_ID //Text = s.POA_ID + "-" + s.PRINTED_NAME }; model.ListPoaFrom = new SelectList(selectList, "Value", "Text");; // GlobalFunctions.GetPoaAll(_poabll); model.ListPoaTo = new SelectList(selectList, "Value", "Text"); } else { var listUsers = _userBll.GetUsers(); var selectList = from s in listUsers select new SelectListItem { Value = s.USER_ID, Text = s.USER_ID }; model.ListPoaFrom = new SelectList(selectList, "Value", "Text");; // GlobalFunctions.GetPoaAll(_poabll); var listUsersTo = _userBll.GetListUserRoleByUserId(model.PoaFrom); var selectListTo = from s in listUsersTo select new SelectListItem { Value = s.UserId, Text = s.UserId }; model.ListPoaTo = new SelectList(selectListTo, "Value", "Text"); } return(model); }
public ActionResult Edit(PoaDelegationFormViewModel model) { if (ModelState.IsValid) { try { SavePoaDelegationToDatabase(model); AddMessageInfo("Success update POA Delegation", Enums.MessageInfoType.Success); return(RedirectToAction("Index")); } catch (Exception ex) { AddMessageInfo("Update Failed : " + ex.Message, Enums.MessageInfoType.Error); } } model = SetListModel(model, false); return(View("Edit", model)); }
public ActionResult Detail(int id) { var model = new PoaDelegationFormViewModel(); try { model = Mapper.Map <PoaDelegationFormViewModel>(_poaDelegationBll.GetById(id)); model.MainMenu = Enums.MenuList.MasterData; model.CurrentMenu = PageInfo; model.ChangesHistoryList = Mapper.Map <List <ChangesHistoryItemModel> >( _changesHistoryBll.GetByFormTypeAndFormId(Enums.MenuList.PoaDelegation, id.ToString())); } catch (Exception ex) { AddMessageInfo(ex.Message, Enums.MessageInfoType.Error); model.MainMenu = Enums.MenuList.MasterData; model.CurrentMenu = PageInfo; } return(View("Detail", model)); }