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