/// <summary> /// Private method to merge in the model /// </summary> /// <returns></returns> private StaffDetailsVM GetUpdatedModel() { StaffDetailsVM model = new StaffDetailsVM(); RepopulateListsFromCacheSession(model); model.Message = ""; if (SessionManager.CurrentStaffDetails != null) { model.StaffDetailsItem = SessionManager.CurrentStaffDetails; } //***************************************NEED WHITE LIST ---- BLACK LIST ------ TO PREVENT OVERPOSTING ************************** bool result = TryUpdateModel(model);//This also validates and sets ModelState //******************************************************************************************************************************* if (SessionManager.CurrentStaffDetails != null) { //*****************************************PREVENT OVER POSTING ATTACKS****************************************************** //Get the values for read only fields from session MergeNewValuesWithOriginal(model.StaffDetailsItem); //*************************************************************************************************************************** } SetAccessContext(model); return(model); }
private void RepopulateListsFromCacheSession(StaffDetailsVM model) { // Populate cached lists if they are empty. Will invoke service call StaffDetailsLookupListsCacheObject CachedLists = CacheManager.StaffDetailsListCache; // Retrieve any cached lists to model model.StaffList = CachedLists.StaffList; model.StaffOfficeList = CachedLists.StaffOfficeList; }
private void SetFlagsFalse(StaffDetailsVM model) { model.IsExitConfirmed = "False"; model.IsNewConfirmed = "False"; //Stop the binder resetting the posted values ModelState.Remove("IsDeleteConfirmed"); ModelState.Remove("IsExitConfirmed"); ModelState.Remove("IsNewConfirmed"); }
public ActionResult Edit() { // Retrieve ID from session string code = SessionManager.StaffDetailsCode; StaffDetailsVM model = new StaffDetailsVM(); // Not from staff or error if (String.IsNullOrEmpty(code)) { //If session has lists then use them RepopulateListsFromCacheSession(model); //Assume we are in create mode as no code passed model.StaffDetailsItem = new StaffDetailsModel(); } //if we have been passed a code then assume we are in edit situation and we need to retrieve from the database. else { // Create service instance AdminServiceClient sc = new AdminServiceClient(); try { // Call service to get StaffDetails item and any associated lookups StaffDetailsVMDC returnedObject = sc.GetStaffDetails(CurrentUser, CurrentUser, appID, "", code); // Close service communication sc.Close(); //Get view model from service model = ConvertStaffDetailsDC(returnedObject); ResolveFieldCodesToFieldNamesUsingLists(model); //Store the service version SessionManager.StaffDetailsServiceVersion = model.StaffDetailsItem; } catch (Exception e) { // Handle the exception string message = ExceptionManager.HandleException(e, sc); model.Message = message; return(View(model)); } } //Adds current retrieved StaffDetails to session SessionManager.CurrentStaffDetails = model.StaffDetailsItem; SetAccessContext(model); return(View(model)); }
private void DetermineIsDirty(StaffDetailsVM model) { //Compare the StaffDetails to the original session if (model.StaffDetailsItem.PublicInstancePropertiesEqual(SessionManager.StaffDetailsServiceVersion, "RowIdentifier")) { model.IsViewDirty = false; } else { model.IsViewDirty = true; } }
private StaffDetailsVM ConvertStaffDetailsDC(StaffDetailsVMDC returnedObject) { StaffDetailsVM model = new StaffDetailsVM(); // Map StaffDetails Item model.StaffDetailsItem = Mapper.Map <StaffDetailsDC, StaffDetailsModel>(returnedObject.StaffDetailsItem); // Map lookup data lists model.StaffList = Mapper.Map <IEnumerable <StaffDC>, List <StaffModel> >(returnedObject.StaffList); model.StaffOfficeList = Mapper.Map <IEnumerable <StaffOfficesDC>, List <StaffOfficesModel> >(returnedObject.StaffOfficeList); return(model); }
private void SetAccessContext(StaffDetailsVM model) { //Decide on access context if (null == model.StaffDetailsItem || model.StaffDetailsItem.Code == Guid.Empty) { // Create context model.AccessContext = StaffDetailsAccessContext.Create; } else { // Edit context model.AccessContext = StaffDetailsAccessContext.Edit; } }
public async Task <IActionResult> StaffsListByAccountant(Int64 StaffId, int pg = 1) { try { var result = new StaffDetails() { StaffId = StaffId }; var staffList = await Task.Run(() => _StaffsServ.StaffDetails(result)); ViewBag.ddlDesignations = _DesignationsServ.dropdown_Designations(); var temp = new StaffDetailsVM_Staffs() { Id = staffList.Staffs.Id, DesignationId = staffList.Staffs.DesignationId, FirstName = staffList.Staffs.FirstName, LastName = staffList.Staffs.LastName, Name = staffList.Staffs.Name, Designation = staffList.Staffs.Designation, Cell = staffList.Staffs.Cell, Email = staffList.Staffs.Email, Education = staffList.Staffs.Education, Address = staffList.Staffs.Address }; var model = new StaffDetailsVM() { Staffs = temp }; return(View("StaffsListByAccountant", model)); } catch { return(BadRequest()); } }
private void ResolveFieldCodesToFieldNamesUsingLists(StaffDetailsVM model) { //TODO: }