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

            GDSThirdPartyVendor thirdPartyVendor = thirdPartyVendorRepository.GetGDSThirdPartyVendor(id);

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

            GDSThirdPartyVendorVM thirdPartyVendorVM = new GDSThirdPartyVendorVM();

            thirdPartyVendorVM.GDSThirdPartyVendor = thirdPartyVendor;

            return(View(thirdPartyVendorVM));
        }
示例#2
0
        //Add GDSThirdPartyVendor
        public void Add(GDSThirdPartyVendorVM gdsGDSThirdPartyVendorVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_InsertGDSThirdPartyVendor_v1(
                gdsGDSThirdPartyVendorVM.GDSThirdPartyVendor.GDSThirdPartyVendorName,
                adminUserGuid
                );
        }
示例#3
0
        //Delete GDSThirdPartyVendor
        public void Delete(GDSThirdPartyVendorVM externalNameVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeleteGDSThirdPartyVendor_v1(
                externalNameVM.GDSThirdPartyVendor.GDSThirdPartyVendorId,
                adminUserGuid,
                externalNameVM.GDSThirdPartyVendor.VersionNumber
                );
        }
        public ActionResult Create(GDSThirdPartyVendorVM thirdPartyVendorVM)
        {
            //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 <GDSThirdPartyVendorVM>(thirdPartyVendorVM, "GDSThirdPartyVendorVM");
            }
            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
            {
                thirdPartyVendorRepository.Add(thirdPartyVendorVM);
            }
            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";
            }

            GDSThirdPartyVendorVM thirdPartyVendorVM = new GDSThirdPartyVendorVM();
            GDSThirdPartyVendor   thirdPartyVendor   = new GDSThirdPartyVendor();

            thirdPartyVendorVM.GDSThirdPartyVendor = thirdPartyVendor;

            return(View(thirdPartyVendorVM));
        }
        public ActionResult Delete(GDSThirdPartyVendorVM thirdPartyVendorVM, 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
            GDSThirdPartyVendor thirdPartyVendor = new GDSThirdPartyVendor();

            thirdPartyVendor = thirdPartyVendorRepository.GetGDSThirdPartyVendor(thirdPartyVendorVM.GDSThirdPartyVendor.GDSThirdPartyVendorId);

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

            //Delete Item
            try
            {
                thirdPartyVendorRepository.Delete(thirdPartyVendorVM);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/GDSThirdPartyVendor.mvc/Delete/" + thirdPartyVendor.GDSThirdPartyVendorId;
                    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)
        {
            GDSThirdPartyVendor thirdPartyVendor = new GDSThirdPartyVendor();

            thirdPartyVendor = thirdPartyVendorRepository.GetGDSThirdPartyVendor(id);

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

            GDSThirdPartyVendorVM thirdPartyVendorVM = new GDSThirdPartyVendorVM();

            thirdPartyVendorVM.AllowDelete = true;

            //Attached Items
            List <GDSThirdPartyVendorReference> thirdPartyVendorReferences = thirdPartyVendorRepository.GetGDSThirdPartyVendorReferences(thirdPartyVendor.GDSThirdPartyVendorId);

            if (thirdPartyVendorReferences.Count > 0)
            {
                thirdPartyVendorVM.AllowDelete = false;
                thirdPartyVendorVM.GDSThirdPartyVendorReferences = thirdPartyVendorReferences;
            }

            thirdPartyVendorVM.GDSThirdPartyVendor = thirdPartyVendor;

            return(View(thirdPartyVendorVM));
        }