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

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

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

            if (sessionManager.CurrentRelationshipToCustomer != null)
            {
                model.RelationshipToCustomerItem = sessionManager.CurrentRelationshipToCustomer;
            }

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

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

            SetAccessContext(model);

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

            RelationshipToCustomerVM model = new RelationshipToCustomerVM();

            // 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.RelationshipToCustomerItem = new RelationshipToCustomerModel()
                {
                    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 RelationshipToCustomer item and any associated lookups
                    RelationshipToCustomerVMDC returnedObject = sc.GetRelationshipToCustomer(CurrentUser, CurrentUser, appID, "", code);

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

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

                    ResolveFieldCodesToFieldNamesUsingLists(model);

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

                    return(View(model));
                }
            }

            //Adds current retrieved RelationshipToCustomer to session
            sessionManager.CurrentRelationshipToCustomer = model.RelationshipToCustomerItem;
            SetAccessContext(model);

            return(View(model));
        }
Example #4
0
        private RelationshipToCustomerVM ConvertRelationshipToCustomerDC(RelationshipToCustomerVMDC returnedObject)
        {
            RelationshipToCustomerVM model = new RelationshipToCustomerVM();

            // Map RelationshipToCustomer Item
            model.RelationshipToCustomerItem = Mapper.Map <RelationshipToCustomerDC, RelationshipToCustomerModel>(returnedObject.RelationshipToCustomerItem);

            // Map lookup data lists

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