Esempio n. 1
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            SystemUserGDSAccessRight systemUserGDSAccessRight = SystemUserGDSAccessRightRepository.GetSystemUserGDSAccessRight(id);

            //Check Exists
            if (systemUserGDSAccessRight == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check Access
            if (!rolesRepository.HasWriteAccessToSystemUserGDSAccessRight(id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            SystemUserGDSAccessRightVM systemUserGDSAccessRightVM = new SystemUserGDSAccessRightVM();

            systemUserGDSAccessRightVM.SystemUserGDSAccessRight = systemUserGDSAccessRight;

            //GDS
            systemUserGDSAccessRightVM.GDSs = new SelectList(gdsRepository.GetAllGDSs().ToList(), "GDSCode", "GDSName", systemUserGDSAccessRight.GDSCode);

            //GDSAccessTypes
            systemUserGDSAccessRightVM.GDSAccessTypes = new SelectList(gdsAccessTypeRepository.GetGDSAccessTypesByGDSCode(systemUserGDSAccessRight.GDSCode).ToList(), "GDSAccessTypeId", "GDSAccessTypeName", systemUserGDSAccessRight.GDSAccessTypeId);

            //PseudoCityOrOfficeIds
            systemUserGDSAccessRightVM.PseudoCityOrOfficeIds = new SelectList(
                systemUserRepository.GetSystemUserPseudoCityOrOfficeIdsByGDSCode(systemUserGDSAccessRight.SystemUserGuid, systemUserGDSAccessRight.GDSCode).ToList(),
                "PseudoCityOrOfficeId",
                "PseudoCityOrOfficeId",
                systemUserGDSAccessRight.PseudoCityOrOfficeId
                );

            //System User
            SystemUser systemUser = new SystemUser();

            systemUser = systemUserRepository.GetUserBySystemUserGuid(systemUserGDSAccessRight.SystemUserGuid);
            if (systemUser != null)
            {
                systemUserGDSAccessRightVM.SystemUser = systemUser;
            }

            return(View(systemUserGDSAccessRightVM));
        }