Пример #1
0
        private void RepopulateListsFromCacheSession(InterestedPartyVM model)
        {
            // Populate cached lists if they are empty. Will invoke service call
            InterestedPartyLookupListsCacheObject CachedLists = cacheManager.InterestedPartyListCache;

            // Retrieve any cached lists to model
        }
Пример #2
0
        /// <summary>
        /// Private method to merge in the model
        /// </summary>
        /// <returns></returns>
        private InterestedPartyVM GetUpdatedModel()
        {
            InterestedPartyVM model = new InterestedPartyVM();

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

            if (sessionManager.CurrentInterestedParty != null)
            {
                model.InterestedPartyItem = sessionManager.CurrentInterestedParty;
            }

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

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

            SetAccessContext(model);

            return(model);
        }
Пример #3
0
        public ActionResult Edit()
        {
            // Retrieve ID from session
            string code = sessionManager.InterestedPartyCode;

            InterestedPartyVM model = new InterestedPartyVM();

            // 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.InterestedPartyItem = new InterestedPartyModel()
                {
                    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 InterestedParty item and any associated lookups
                    InterestedPartyVMDC returnedObject = sc.GetInterestedParty(CurrentUser, CurrentUser, appID, "", code);

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

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

                    ResolveFieldCodesToFieldNamesUsingLists(model);

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

                    return(View(model));
                }
            }

            //Adds current retrieved InterestedParty to session
            sessionManager.CurrentInterestedParty = model.InterestedPartyItem;
            SetAccessContext(model);

            return(View(model));
        }
Пример #4
0
        private InterestedPartyVM ConvertInterestedPartyDC(InterestedPartyVMDC returnedObject)
        {
            InterestedPartyVM model = new InterestedPartyVM();

            // Map InterestedParty Item
            model.InterestedPartyItem = Mapper.Map <InterestedPartyDC, InterestedPartyModel>(returnedObject.InterestedPartyItem);

            // Map lookup data lists

            return(model);
        }
Пример #5
0
        private void SetFlagsFalse(InterestedPartyVM 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");
        }
Пример #6
0
 private void DetermineIsDirty(InterestedPartyVM model)
 {
     //Compare the InterestedParty to the original session
     if (model.InterestedPartyItem.PublicInstancePropertiesEqual(sessionManager.InterestedPartyServiceVersion, "RowIdentifier"))
     {
         model.IsViewDirty = false;
     }
     else
     {
         model.IsViewDirty = true;
     }
 }
Пример #7
0
 private void SetAccessContext(InterestedPartyVM model)
 {
     //Decide on access context
     if (null == model.InterestedPartyItem || model.InterestedPartyItem.Code == Guid.Empty)
     {
         // Create context
         model.AccessContext = InterestedPartyAccessContext.Create;
     }
     else
     {
         // Edit context
         model.AccessContext = InterestedPartyAccessContext.Edit;
     }
 }
Пример #8
0
 private void ResolveFieldCodesToFieldNamesUsingLists(InterestedPartyVM model)
 {
     //TODO:
 }