// GET: /Edit
        public ActionResult Edit(int id)
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Access"] = "WriteAccess";
            }

            PseudoCityOrOfficeLocationType pseudoCityOrOfficeLocationType = pseudoCityOrOfficeLocationTypeRepository.GetPseudoCityOrOfficeLocationType(id);

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

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            PseudoCityOrOfficeLocationTypeVM pseudoCityOrOfficeLocationTypeVM = new PseudoCityOrOfficeLocationTypeVM();

            pseudoCityOrOfficeLocationTypeVM.PseudoCityOrOfficeLocationType = pseudoCityOrOfficeLocationType;

            return(View(pseudoCityOrOfficeLocationTypeVM));
        }
예제 #2
0
        //Add PseudoCityOrOfficeLocationType
        public void Add(PseudoCityOrOfficeLocationTypeVM gdsPseudoCityOrOfficeLocationTypeVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_InsertPseudoCityOrOfficeLocationType_v1(
                gdsPseudoCityOrOfficeLocationTypeVM.PseudoCityOrOfficeLocationType.PseudoCityOrOfficeLocationTypeName,
                adminUserGuid
                );
        }
예제 #3
0
        //Delete PseudoCityOrOfficeLocationType
        public void Delete(PseudoCityOrOfficeLocationTypeVM pseudoCityOrOfficeLocationTypeVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeletePseudoCityOrOfficeLocationType_v1(
                pseudoCityOrOfficeLocationTypeVM.PseudoCityOrOfficeLocationType.PseudoCityOrOfficeLocationTypeId,
                adminUserGuid,
                pseudoCityOrOfficeLocationTypeVM.PseudoCityOrOfficeLocationType.VersionNumber
                );
        }
        public ActionResult Create(PseudoCityOrOfficeLocationTypeVM pseudoCityOrOfficeLocationTypeVM)
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Access"] = "WriteAccess";
            }

            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Update  Model from Form
            try
            {
                TryUpdateModel <PseudoCityOrOfficeLocationTypeVM>(pseudoCityOrOfficeLocationTypeVM, "GDSPseudoCityOrOfficeLocationTypeVM");
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            try
            {
                pseudoCityOrOfficeLocationTypeRepository.Add(pseudoCityOrOfficeLocationTypeVM);
            }
            catch (SqlException ex)
            {
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            return(RedirectToAction("List"));
        }
        public ActionResult Create()
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Access"] = "WriteAccess";
            }

            PseudoCityOrOfficeLocationTypeVM pseudoCityOrOfficeLocationTypeVM = new PseudoCityOrOfficeLocationTypeVM();
            PseudoCityOrOfficeLocationType   pseudoCityOrOfficeLocationType   = new PseudoCityOrOfficeLocationType();

            pseudoCityOrOfficeLocationTypeVM.PseudoCityOrOfficeLocationType = pseudoCityOrOfficeLocationType;

            return(View(pseudoCityOrOfficeLocationTypeVM));
        }
        public ActionResult Delete(PseudoCityOrOfficeLocationTypeVM pseudoCityOrOfficeLocationTypeVM, FormCollection collection)
        {
            //Check Access
            RolesRepository rolesRepository = new RolesRepository();

            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Get Item From Database
            PseudoCityOrOfficeLocationType pseudoCityOrOfficeLocationType = new PseudoCityOrOfficeLocationType();

            pseudoCityOrOfficeLocationType = pseudoCityOrOfficeLocationTypeRepository.GetPseudoCityOrOfficeLocationType(pseudoCityOrOfficeLocationTypeVM.PseudoCityOrOfficeLocationType.PseudoCityOrOfficeLocationTypeId);

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

            //Delete Item
            try
            {
                pseudoCityOrOfficeLocationTypeRepository.Delete(pseudoCityOrOfficeLocationTypeVM);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PseudoCityOrOfficeLocationType.mvc/Delete/" + pseudoCityOrOfficeLocationType.PseudoCityOrOfficeLocationTypeId;
                    return(View("VersionError"));
                }
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }
            return(RedirectToAction("List"));
        }
        public ActionResult Delete(int id)
        {
            PseudoCityOrOfficeLocationType pseudoCityOrOfficeLocationType = new PseudoCityOrOfficeLocationType();

            pseudoCityOrOfficeLocationType = pseudoCityOrOfficeLocationTypeRepository.GetPseudoCityOrOfficeLocationType(id);

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

            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            PseudoCityOrOfficeLocationTypeVM pseudoCityOrOfficeLocationTypeVM = new PseudoCityOrOfficeLocationTypeVM();

            pseudoCityOrOfficeLocationTypeVM.AllowDelete = true;

            //Attached Items
            List <PseudoCityOrOfficeLocationTypeReference> pseudoCityOrOfficeLocationTypeReferences = pseudoCityOrOfficeLocationTypeRepository.GetPseudoCityOrOfficeLocationTypeReferences(pseudoCityOrOfficeLocationType.PseudoCityOrOfficeLocationTypeId);

            if (pseudoCityOrOfficeLocationTypeReferences.Count > 0)
            {
                pseudoCityOrOfficeLocationTypeVM.AllowDelete = false;
                pseudoCityOrOfficeLocationTypeVM.PseudoCityOrOfficeLocationTypeReferences = pseudoCityOrOfficeLocationTypeReferences;
            }

            pseudoCityOrOfficeLocationTypeVM.PseudoCityOrOfficeLocationType = pseudoCityOrOfficeLocationType;

            return(View(pseudoCityOrOfficeLocationTypeVM));
        }