private void RepopulateListsFromCacheSession(IncidentCategoryVM model) { // Populate cached lists if they are empty. Will invoke service call IncidentCategoryLookupListsCacheObject CachedLists = cacheManager.IncidentCategoryListCache; // Retrieve any cached lists to model }
/// <summary> /// Private method to merge in the model /// </summary> /// <returns></returns> private IncidentCategoryVM GetUpdatedModel() { IncidentCategoryVM model = new IncidentCategoryVM(); RepopulateListsFromCacheSession(model); model.Message = ""; if (sessionManager.CurrentIncidentCategory != null) { model.IncidentCategoryItem = sessionManager.CurrentIncidentCategory; } //***************************************NEED WHITE LIST ---- BLACK LIST ------ TO PREVENT OVERPOSTING ************************** bool result = TryUpdateModel(model);//This also validates and sets ModelState //******************************************************************************************************************************* if (sessionManager.CurrentIncidentCategory != null) { //*****************************************PREVENT OVER POSTING ATTACKS****************************************************** //Get the values for read only fields from session MergeNewValuesWithOriginal(model.IncidentCategoryItem); //*************************************************************************************************************************** } SetAccessContext(model); return(model); }
public ActionResult Edit() { // Retrieve ID from session string code = sessionManager.IncidentCategoryCode; IncidentCategoryVM model = new IncidentCategoryVM(); // 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.IncidentCategoryItem = new IncidentCategoryModel() { 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 IncidentCategory item and any associated lookups IncidentCategoryVMDC returnedObject = sc.GetIncidentCategory(CurrentUser, CurrentUser, appID, "", code); // Close service communication ((ICommunicationObject)sc).Close(); //Get view model from service model = ConvertIncidentCategoryDC(returnedObject); ResolveFieldCodesToFieldNamesUsingLists(model); //Store the service version sessionManager.IncidentCategoryServiceVersion = model.IncidentCategoryItem; } catch (Exception e) { // Handle the exception string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc); model.Message = message; return(View(model)); } } //Adds current retrieved IncidentCategory to session sessionManager.CurrentIncidentCategory = model.IncidentCategoryItem; SetAccessContext(model); return(View(model)); }
private IncidentCategoryVM ConvertIncidentCategoryDC(IncidentCategoryVMDC returnedObject) { IncidentCategoryVM model = new IncidentCategoryVM(); // Map IncidentCategory Item model.IncidentCategoryItem = Mapper.Map <IncidentCategoryDC, IncidentCategoryModel>(returnedObject.IncidentCategoryItem); // Map lookup data lists return(model); }
private void SetFlagsFalse(IncidentCategoryVM 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(IncidentCategoryVM model) { //Compare the IncidentCategory to the original session if (model.IncidentCategoryItem.PublicInstancePropertiesEqual(sessionManager.IncidentCategoryServiceVersion, "RowIdentifier")) { model.IsViewDirty = false; } else { model.IsViewDirty = true; } }
private void SetAccessContext(IncidentCategoryVM model) { //Decide on access context if (null == model.IncidentCategoryItem || model.IncidentCategoryItem.Code == Guid.Empty) { // Create context model.AccessContext = IncidentCategoryAccessContext.Create; } else { // Edit context model.AccessContext = IncidentCategoryAccessContext.Edit; } }
private void ResolveFieldCodesToFieldNamesUsingLists(IncidentCategoryVM model) { //TODO: }