Ejemplo n.º 1
0
        /// <summary>
        /// Private method to merge in the model
        /// </summary>
        /// <returns></returns>
        private IncidentInterestedPartyVM GetUpdatedModel()
        {
            IncidentInterestedPartyVM model = new IncidentInterestedPartyVM();

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

            if (sessionManager.CurrentIncidentInterestedParty != null)
            {
                model.IncidentInterestedPartyItem = sessionManager.CurrentIncidentInterestedParty;
            }

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

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

            SetAccessContext(model);

            return(model);
        }
Ejemplo n.º 2
0
        private void RepopulateListsFromCacheSession(IncidentInterestedPartyVM model)
        {
            // Populate cached lists if they are empty. Will invoke service call
            IncidentInterestedPartyLookupListsCacheObject CachedLists = cacheManager.IncidentInterestedPartyListCache;

            // Retrieve any cached lists to model
            model.IncidentList        = CachedLists.IncidentList;
            model.InterestedPartyList = CachedLists.InterestedPartyList;
        }
Ejemplo n.º 3
0
        public ActionResult Edit()
        {
            // Retrieve ID from session
            string code = sessionManager.IncidentInterestedPartyCode;

            IncidentInterestedPartyVM model = new IncidentInterestedPartyVM();

            // 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.IncidentInterestedPartyItem = new IncidentInterestedPartyModel();
            }
            //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 IncidentInterestedParty item and any associated lookups
                    IncidentInterestedPartyVMDC returnedObject = sc.GetIncidentInterestedParty(CurrentUser, CurrentUser, appID, "", code);

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

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

                    ResolveFieldCodesToFieldNamesUsingLists(model);

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

                    return(View(model));
                }
            }

            //Adds current retrieved IncidentInterestedParty to session
            sessionManager.CurrentIncidentInterestedParty = model.IncidentInterestedPartyItem;
            SetAccessContext(model);

            return(View(model));
        }
Ejemplo n.º 4
0
        private void SetFlagsFalse(IncidentInterestedPartyVM 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");
        }
Ejemplo n.º 5
0
 private void DetermineIsDirty(IncidentInterestedPartyVM model)
 {
     //Compare the IncidentInterestedParty to the original session
     if (model.IncidentInterestedPartyItem.PublicInstancePropertiesEqual(sessionManager.IncidentInterestedPartyServiceVersion, "RowIdentifier"))
     {
         model.IsViewDirty = false;
     }
     else
     {
         model.IsViewDirty = true;
     }
 }
Ejemplo n.º 6
0
        private IncidentInterestedPartyVM ConvertIncidentInterestedPartyDC(IncidentInterestedPartyVMDC returnedObject)
        {
            IncidentInterestedPartyVM model = new IncidentInterestedPartyVM();

            // Map IncidentInterestedParty Item
            model.IncidentInterestedPartyItem = Mapper.Map <IncidentInterestedPartyDC, IncidentInterestedPartyModel>(returnedObject.IncidentInterestedPartyItem);

            // Map lookup data lists
            model.IncidentList        = Mapper.Map <IEnumerable <IncidentDC>, List <IncidentModel> >(returnedObject.IncidentList);
            model.InterestedPartyList = Mapper.Map <IEnumerable <InterestedPartyDC>, List <InterestedPartyModel> >(returnedObject.InterestedPartyList);

            return(model);
        }
Ejemplo n.º 7
0
 private void SetAccessContext(IncidentInterestedPartyVM model)
 {
     //Decide on access context
     if (null == model.IncidentInterestedPartyItem || model.IncidentInterestedPartyItem.Code == Guid.Empty)
     {
         // Create context
         model.AccessContext = IncidentInterestedPartyAccessContext.Create;
     }
     else
     {
         // Edit context
         model.AccessContext = IncidentInterestedPartyAccessContext.Edit;
     }
 }
Ejemplo n.º 8
0
 private void ResolveFieldCodesToFieldNamesUsingLists(IncidentInterestedPartyVM model)
 {
     //TODO:
 }