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