Example #1
0
        private void RepopulateListsFromCacheSession(IncidentLocationVM model)
        {
            // Populate cached lists if they are empty. Will invoke service call
            IncidentLocationLookupListsCacheObject CachedLists = cacheManager.IncidentLocationListCache;

            // Retrieve any cached lists to model
        }
Example #2
0
        /// <summary>
        /// Private method to merge in the model
        /// </summary>
        /// <returns></returns>
        private IncidentLocationVM GetUpdatedModel()
        {
            IncidentLocationVM model = new IncidentLocationVM();

            RepopulateListsFromCacheSession(model);
            model.Message = "";

            if (sessionManager.CurrentIncidentLocation != null)
            {
                model.IncidentLocationItem = sessionManager.CurrentIncidentLocation;
            }

            //***************************************NEED WHITE LIST ---- BLACK LIST ------ TO PREVENT OVERPOSTING **************************
            bool result = TryUpdateModel(model);//This also validates and sets ModelState

            //*******************************************************************************************************************************
            if (sessionManager.CurrentIncidentLocation != null)
            {
                //*****************************************PREVENT OVER POSTING ATTACKS******************************************************
                //Get the values for read only fields from session
                MergeNewValuesWithOriginal(model.IncidentLocationItem);
                //***************************************************************************************************************************
            }

            SetAccessContext(model);

            return(model);
        }
Example #3
0
        public ActionResult Edit()
        {
            // Retrieve ID from session
            string code = sessionManager.IncidentLocationCode;

            IncidentLocationVM model = new IncidentLocationVM();

            // 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.IncidentLocationItem = new IncidentLocationModel()
                {
                    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 IncidentLocation item and any associated lookups
                    IncidentLocationVMDC returnedObject = sc.GetIncidentLocation(CurrentUser, CurrentUser, appID, "", code);

                    // Close service communication
                    ((ICommunicationObject)sc).Close();

                    //Get view model from service
                    model = ConvertIncidentLocationDC(returnedObject);

                    ResolveFieldCodesToFieldNamesUsingLists(model);

                    //Store the service version
                    sessionManager.IncidentLocationServiceVersion = model.IncidentLocationItem;
                }
                catch (Exception e)
                {
                    // Handle the exception
                    string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                    model.Message = message;

                    return(View(model));
                }
            }

            //Adds current retrieved IncidentLocation to session
            sessionManager.CurrentIncidentLocation = model.IncidentLocationItem;
            SetAccessContext(model);

            return(View(model));
        }
Example #4
0
        private IncidentLocationVM ConvertIncidentLocationDC(IncidentLocationVMDC returnedObject)
        {
            IncidentLocationVM model = new IncidentLocationVM();

            // Map IncidentLocation Item
            model.IncidentLocationItem = Mapper.Map <IncidentLocationDC, IncidentLocationModel>(returnedObject.IncidentLocationItem);

            // Map lookup data lists

            return(model);
        }
Example #5
0
        private void SetFlagsFalse(IncidentLocationVM 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");
        }
Example #6
0
 private void DetermineIsDirty(IncidentLocationVM model)
 {
     //Compare the IncidentLocation to the original session
     if (model.IncidentLocationItem.PublicInstancePropertiesEqual(sessionManager.IncidentLocationServiceVersion, "RowIdentifier"))
     {
         model.IsViewDirty = false;
     }
     else
     {
         model.IsViewDirty = true;
     }
 }
Example #7
0
 private void SetAccessContext(IncidentLocationVM model)
 {
     //Decide on access context
     if (null == model.IncidentLocationItem || model.IncidentLocationItem.Code == Guid.Empty)
     {
         // Create context
         model.AccessContext = IncidentLocationAccessContext.Create;
     }
     else
     {
         // Edit context
         model.AccessContext = IncidentLocationAccessContext.Edit;
     }
 }
Example #8
0
 private void ResolveFieldCodesToFieldNamesUsingLists(IncidentLocationVM model)
 {
     //TODO:
 }