コード例 #1
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Access"] = "WriteAccess";
            }

            ExternalName externalName = externalNameRepository.GetExternalName(id);

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

            ExternalNameVM externalNameVM = new ExternalNameVM();

            externalNameVM.ExternalName = externalName;

            return(View(externalNameVM));
        }
コード例 #2
0
        //Add ExternalName
        public void Add(ExternalNameVM gdsExternalNameVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_InsertExternalName_v1(
                gdsExternalNameVM.ExternalName.ExternalName1,
                adminUserGuid
                );
        }
コード例 #3
0
        //Delete ExternalName
        public void Delete(ExternalNameVM externalNameVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeleteExternalName_v1(
                externalNameVM.ExternalName.ExternalNameId,
                adminUserGuid,
                externalNameVM.ExternalName.VersionNumber
                );
        }
コード例 #4
0
        //Edit ExternalName
        public void Update(ExternalNameVM externalNameVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_UpdateExternalName_v1(
                externalNameVM.ExternalName.ExternalNameId,
                externalNameVM.ExternalName.ExternalName1,
                adminUserGuid
                );
        }
コード例 #5
0
        public ActionResult Create(ExternalNameVM externalNameVM)
        {
            //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 <ExternalNameVM>(externalNameVM, "GDSExternalNameVM");
            }
            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
            {
                externalNameRepository.Add(externalNameVM);
            }
            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"));
        }
コード例 #6
0
        public ActionResult Create()
        {
            //Set Access Rights
            ViewData["Access"] = "";
            if (hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Access"] = "WriteAccess";
            }

            ExternalNameVM externalNameVM = new ExternalNameVM();
            ExternalName   externalName   = new ExternalName();

            externalNameVM.ExternalName = externalName;

            return(View(externalNameVM));
        }
コード例 #7
0
        public ActionResult Delete(ExternalNameVM externalNameVM, 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
            ExternalName externalName = new ExternalName();

            externalName = externalNameRepository.GetExternalName(externalNameVM.ExternalName.ExternalNameId);

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

            //Delete Item
            try
            {
                externalNameRepository.Delete(externalNameVM);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/ExternalName.mvc/Delete/" + externalName.ExternalNameId;
                    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"));
        }
コード例 #8
0
        public ActionResult Delete(int id)
        {
            ExternalName externalName = new ExternalName();

            externalName = externalNameRepository.GetExternalName(id);

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

            ExternalNameVM externalNameVM = new ExternalNameVM();

            externalNameVM.AllowDelete = true;

            //Attached Items
            List <ExternalNameReference> externalNameReferences = externalNameRepository.GetExternalNameReferences(externalName.ExternalNameId);

            if (externalNameReferences.Count > 0)
            {
                externalNameVM.AllowDelete            = false;
                externalNameVM.ExternalNameReferences = externalNameReferences;
            }

            externalNameVM.ExternalName = externalName;

            return(View(externalNameVM));
        }