コード例 #1
0
        private void RepopulateListsFromCacheSession(JobRoleVM model)
        {
            // Populate cached lists if they are empty. Will invoke service call
            JobRoleLookupListsCacheObject CachedLists = cacheManager.JobRoleListCache;

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

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

            if (sessionManager.CurrentJobRole != null)
            {
                model.JobRoleItem = sessionManager.CurrentJobRole;
            }

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

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

            SetAccessContext(model);

            return(model);
        }
コード例 #3
0
        public ActionResult Edit()
        {
            // Retrieve ID from session
            string code = sessionManager.JobRoleCode;

            JobRoleVM model = new JobRoleVM();

            // 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.JobRoleItem = new JobRoleModel()
                {
                    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 JobRole item and any associated lookups
                    JobRoleVMDC returnedObject = sc.GetJobRole(CurrentUser, CurrentUser, appID, "", code);

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

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

                    ResolveFieldCodesToFieldNamesUsingLists(model);

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

                    return(View(model));
                }
            }

            //Adds current retrieved JobRole to session
            sessionManager.CurrentJobRole = model.JobRoleItem;
            SetAccessContext(model);

            return(View(model));
        }
コード例 #4
0
        private JobRoleVM ConvertJobRoleDC(JobRoleVMDC returnedObject)
        {
            JobRoleVM model = new JobRoleVM();

            // Map JobRole Item
            model.JobRoleItem = Mapper.Map <JobRoleDC, JobRoleModel>(returnedObject.JobRoleItem);

            // Map lookup data lists

            return(model);
        }
コード例 #5
0
        private void SetFlagsFalse(JobRoleVM 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(JobRoleVM model)
 {
     //Compare the JobRole to the original session
     if (model.JobRoleItem.PublicInstancePropertiesEqual(sessionManager.JobRoleServiceVersion, "RowIdentifier"))
     {
         model.IsViewDirty = false;
     }
     else
     {
         model.IsViewDirty = true;
     }
 }
コード例 #7
0
 private void SetAccessContext(JobRoleVM model)
 {
     //Decide on access context
     if (null == model.JobRoleItem || model.JobRoleItem.Code == Guid.Empty)
     {
         // Create context
         model.AccessContext = JobRoleAccessContext.Create;
     }
     else
     {
         // Edit context
         model.AccessContext = JobRoleAccessContext.Edit;
     }
 }
コード例 #8
0
 private void ResolveFieldCodesToFieldNamesUsingLists(JobRoleVM model)
 {
     //TODO:
 }
コード例 #9
0
 internal CompositeJobRoleVM(JobRoleVM jobRoleVM)
 {
     JobRoleVM = jobRoleVM;
     JobRoleVM.PropertyChanged += OnUpperHierarchyJobRoleChanged;
 }