/// <summary> /// Private method to merge in the model /// </summary> /// <returns></returns> private ADRoleLookupVM GetUpdatedModel() { ADRoleLookupVM model = new ADRoleLookupVM(); RepopulateListsFromCacheSession(model); model.Message = ""; if (sessionManager.CurrentADRoleLookup != null) { model.ADRoleLookupItem = sessionManager.CurrentADRoleLookup; } //***************************************NEED WHITE LIST ---- BLACK LIST ------ TO PREVENT OVERPOSTING ************************** bool result = TryUpdateModel(model);//This also validates and sets ModelState //******************************************************************************************************************************* if (sessionManager.CurrentADRoleLookup != null) { //*****************************************PREVENT OVER POSTING ATTACKS****************************************************** //Get the values for read only fields from session MergeNewValuesWithOriginal(model.ADRoleLookupItem); //*************************************************************************************************************************** } SetAccessContext(model); return(model); }
private void RepopulateListsFromCacheSession(ADRoleLookupVM model) { // Populate cached lists if they are empty. Will invoke service call ADRoleLookupLookupListsCacheObject CachedLists = cacheManager.ADRoleLookupListCache; // Retrieve any cached lists to model model.RoleList = CachedLists.RoleList; }
public ActionResult Edit() { // Retrieve ID from session string code = sessionManager.ADRoleLookupCode; ADRoleLookupVM model = new ADRoleLookupVM(); // 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.ADRoleLookupItem = new ADRoleLookupModel() { IsActive = true }; } //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 IUcbService sc = UcbService; try { // Call service to get ADRoleLookup item and any associated lookups ADRoleLookupVMDC returnedObject = sc.GetADRoleLookup(CurrentUser, CurrentUser, appID, "", code); // Close service communication ((ICommunicationObject)sc).Close(); //Get view model from service model = ConvertADRoleLookupDC(returnedObject); ResolveFieldCodesToFieldNamesUsingLists(model); //Store the service version sessionManager.ADRoleLookupServiceVersion = model.ADRoleLookupItem; } catch (Exception e) { // Handle the exception string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc); model.Message = message; return(View(model)); } } //Adds current retrieved ADRoleLookup to session sessionManager.CurrentADRoleLookup = model.ADRoleLookupItem; SetAccessContext(model); return(View(model)); }
private void SetFlagsFalse(ADRoleLookupVM model) { model.IsDeleteConfirmed = "False"; model.IsExitConfirmed = "False"; model.IsNewConfirmed = "False"; //Stop the binder resetting the posted values ModelState.Remove("IsDeleteConfirmed"); ModelState.Remove("IsExitConfirmed"); ModelState.Remove("IsNewConfirmed"); }
private void DetermineIsDirty(ADRoleLookupVM model) { //Compare the ADRoleLookup to the original session if (model.ADRoleLookupItem.PublicInstancePropertiesEqual(sessionManager.ADRoleLookupServiceVersion, "RowIdentifier")) { model.IsViewDirty = false; } else { model.IsViewDirty = true; } }
private ADRoleLookupVM ConvertADRoleLookupDC(ADRoleLookupVMDC returnedObject) { ADRoleLookupVM model = new ADRoleLookupVM(); // Map ADRoleLookup Item model.ADRoleLookupItem = Mapper.Map <ADRoleLookupDC, ADRoleLookupModel>(returnedObject.ADRoleLookupItem); // Map lookup data lists model.RoleList = Mapper.Map <IEnumerable <RoleDC>, List <RoleModel> >(returnedObject.RoleList); return(model); }
private void SetAccessContext(ADRoleLookupVM model) { //Decide on access context if (null == model.ADRoleLookupItem || model.ADRoleLookupItem.Code == Guid.Empty) { // Create context model.AccessContext = ADRoleLookupAccessContext.Create; } else { // Edit context model.AccessContext = ADRoleLookupAccessContext.Edit; } }
private void ResolveFieldCodesToFieldNamesUsingLists(ADRoleLookupVM model) { //TODO: }