private void RepopulateListsFromCacheSession(StaffOfficesVM model) { // Populate cached lists if they are empty. Will invoke service call StaffOfficesLookupListsCacheObject CachedLists = CacheManager.StaffOfficesListCache; // Retrieve any cached lists to model }
/// <summary> /// Private method to merge in the model /// </summary> /// <returns></returns> private StaffOfficesVM GetUpdatedModel() { StaffOfficesVM model = new StaffOfficesVM(); RepopulateListsFromCacheSession(model); model.Message = ""; if (SessionManager.CurrentStaffOffices != null) { model.StaffOfficesItem = SessionManager.CurrentStaffOffices; } //***************************************NEED WHITE LIST ---- BLACK LIST ------ TO PREVENT OVERPOSTING ************************** bool result = TryUpdateModel(model);//This also validates and sets ModelState //******************************************************************************************************************************* if (SessionManager.CurrentStaffOffices != null) { //*****************************************PREVENT OVER POSTING ATTACKS****************************************************** //Get the values for read only fields from session MergeNewValuesWithOriginal(model.StaffOfficesItem); //*************************************************************************************************************************** } SetAccessContext(model); return(model); }
private void SetFlagsFalse(StaffOfficesVM model) { model.IsExitConfirmed = "False"; model.IsNewConfirmed = "False"; //Stop the binder resetting the posted values ModelState.Remove("IsDeleteConfirmed"); ModelState.Remove("IsExitConfirmed"); ModelState.Remove("IsNewConfirmed"); }
private StaffOfficesVM ConvertStaffOfficesDC(StaffOfficesVMDC returnedObject) { StaffOfficesVM model = new StaffOfficesVM(); // Map StaffOffices Item model.StaffOfficesItem = Mapper.Map <StaffOfficesDC, StaffOfficesModel>(returnedObject.StaffOfficesItem); // Map lookup data lists return(model); }
public ActionResult Edit() { // Retrieve ID from session string code = SessionManager.StaffOfficesCode; StaffOfficesVM model = new StaffOfficesVM(); // 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.StaffOfficesItem = new StaffOfficesModel(); } //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 StaffOffices item and any associated lookups StaffOfficesVMDC returnedObject = sc.GetStaffOffices(CurrentUser, CurrentUser, appID, "", code); // Close service communication sc.Close(); //Get view model from service model = ConvertStaffOfficesDC(returnedObject); ResolveFieldCodesToFieldNamesUsingLists(model); //Store the service version SessionManager.StaffOfficesServiceVersion = model.StaffOfficesItem; } catch (Exception e) { // Handle the exception string message = ExceptionManager.HandleException(e, sc); model.Message = message; return(View(model)); } } //Adds current retrieved StaffOffices to session SessionManager.CurrentStaffOffices = model.StaffOfficesItem; SetAccessContext(model); return(View(model)); }
private void DetermineIsDirty(StaffOfficesVM model) { //Compare the StaffOffices to the original session if (model.StaffOfficesItem.PublicInstancePropertiesEqual(SessionManager.StaffOfficesServiceVersion, "RowIdentifier")) { model.IsViewDirty = false; } else { model.IsViewDirty = true; } }
private void SetAccessContext(StaffOfficesVM model) { //Decide on access context if (null == model.StaffOfficesItem || model.StaffOfficesItem.Code == Guid.Empty) { // Create context model.AccessContext = StaffOfficesAccessContext.Create; } else { // Edit context model.AccessContext = StaffOfficesAccessContext.Edit; } }
private void ResolveFieldCodesToFieldNamesUsingLists(StaffOfficesVM model) { //TODO: }