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