Exemplo n.º 1
0
        private void RepopulateListsFromCacheSession(SystemMarkedVM model)
        {
            // Populate cached lists if they are empty. Will invoke service call
            SystemMarkedLookupListsCacheObject CachedLists = cacheManager.SystemMarkedListCache;

            // Retrieve any cached lists to model
        }
Exemplo n.º 2
0
        /// <summary>
        /// Private method to merge in the model
        /// </summary>
        /// <returns></returns>
        private SystemMarkedVM GetUpdatedModel()
        {
            SystemMarkedVM model = new SystemMarkedVM();

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

            if (sessionManager.CurrentSystemMarked != null)
            {
                model.SystemMarkedItem = sessionManager.CurrentSystemMarked;
            }

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

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

            SetAccessContext(model);

            return(model);
        }
Exemplo n.º 3
0
        public ActionResult Edit()
        {
            // Retrieve ID from session
            string code = sessionManager.SystemMarkedCode;

            SystemMarkedVM model = new SystemMarkedVM();

            // 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.SystemMarkedItem = new SystemMarkedModel()
                {
                    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 SystemMarked item and any associated lookups
                    SystemMarkedVMDC returnedObject = sc.GetSystemMarked(CurrentUser, CurrentUser, appID, "", code);

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

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

                    ResolveFieldCodesToFieldNamesUsingLists(model);

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

                    return(View(model));
                }
            }

            //Adds current retrieved SystemMarked to session
            sessionManager.CurrentSystemMarked = model.SystemMarkedItem;
            SetAccessContext(model);

            return(View(model));
        }
Exemplo n.º 4
0
        private SystemMarkedVM ConvertSystemMarkedDC(SystemMarkedVMDC returnedObject)
        {
            SystemMarkedVM model = new SystemMarkedVM();

            // Map SystemMarked Item
            model.SystemMarkedItem = Mapper.Map <SystemMarkedDC, SystemMarkedModel>(returnedObject.SystemMarkedItem);

            // Map lookup data lists

            return(model);
        }
Exemplo n.º 5
0
        private void SetFlagsFalse(SystemMarkedVM 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");
        }
Exemplo n.º 6
0
 private void DetermineIsDirty(SystemMarkedVM model)
 {
     //Compare the SystemMarked to the original session
     if (model.SystemMarkedItem.PublicInstancePropertiesEqual(sessionManager.SystemMarkedServiceVersion, "RowIdentifier"))
     {
         model.IsViewDirty = false;
     }
     else
     {
         model.IsViewDirty = true;
     }
 }
Exemplo n.º 7
0
 private void SetAccessContext(SystemMarkedVM model)
 {
     //Decide on access context
     if (null == model.SystemMarkedItem || model.SystemMarkedItem.Code == Guid.Empty)
     {
         // Create context
         model.AccessContext = SystemMarkedAccessContext.Create;
     }
     else
     {
         // Edit context
         model.AccessContext = SystemMarkedAccessContext.Edit;
     }
 }
Exemplo n.º 8
0
 private void ResolveFieldCodesToFieldNamesUsingLists(SystemMarkedVM model)
 {
     //TODO:
 }