public ActionResult Delete(GDSAccessTypeVM gdsAccessTypeVM, 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
            GDSAccessType gdsAccessType = new GDSAccessType();

            gdsAccessType = gdsAccessTypeRepository.GetGDSAccessType(gdsAccessTypeVM.GDSAccessType.GDSAccessTypeId);

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

            //Delete Item
            try
            {
                gdsAccessTypeRepository.Delete(gdsAccessTypeVM);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/GDSAccessType.mvc/Delete/" + gdsAccessType.GDSAccessTypeId;
                    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 Create()
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Access"] = "WriteAccess";
            }

            GDSAccessTypeVM gdsAccessTypeVM = new GDSAccessTypeVM();

            GDSAccessType gdsAccessType = new GDSAccessType();

            gdsAccessTypeVM.GDSAccessType = gdsAccessType;

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

            return(View(gdsAccessTypeVM));
        }
        public ActionResult Delete(int id)
        {
            GDSAccessType gdsAccessType = new GDSAccessType();

            gdsAccessType = gdsAccessTypeRepository.GetGDSAccessType(id);

            //Check Exists
            if (gdsAccessType == 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"));
            }

            GDSAccessTypeVM gdsAccessTypeVM = new GDSAccessTypeVM();

            gdsAccessTypeVM.AllowDelete = true;

            //Attached Items
            List <GDSAccessTypeReference> gdsAccessTypeReferences = gdsAccessTypeRepository.GetGDSAccessTypeReferences(gdsAccessType.GDSAccessTypeId);

            if (gdsAccessTypeReferences.Count > 0)
            {
                gdsAccessTypeVM.AllowDelete             = false;
                gdsAccessTypeVM.GDSAccessTypeReferences = gdsAccessTypeReferences;
            }

            gdsAccessTypeVM.GDSAccessType = gdsAccessType;

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

            GDSAccessType gdsAccessType = gdsAccessTypeRepository.GetGDSAccessType(id);

            //Check Exists
            if (gdsAccessType == 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"));
            }

            GDSAccessTypeVM gdsAccessTypeVM = new GDSAccessTypeVM();

            gdsAccessTypeVM.GDSAccessType = gdsAccessType;

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

            return(View(gdsAccessTypeVM));
        }
 public GDSAccessTypeVM(GDSAccessType gdsAccessType, List <GDSAccessTypeReference> gdsAccessTypeReferences)
 {
     GDSAccessType           = gdsAccessType;
     GDSAccessTypeReferences = gdsAccessTypeReferences;
 }