// 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));
        }
        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));
        }
Esempio n. 3
0
        //Get PseudoCityOrOfficeMaintenance GDSThirdPartyVendors
        public List <GDSThirdPartyVendor> GetGDSThirdPartyVendorsByPseudoCityOrOfficeMaintenanceId(int pseudoCityOrOfficeMaintenanceId)
        {
            List <GDSThirdPartyVendor> gdsThirdPartyVendors = new List <GDSThirdPartyVendor>();

            List <PseudoCityOrOfficeMaintenanceGDSThirdPartyVendor> pseudoCityOrOfficeMaintenanceGDSThirdPartyVendors = db.PseudoCityOrOfficeMaintenanceGDSThirdPartyVendors.Where(x => x.PseudoCityOrOfficeMaintenanceId == pseudoCityOrOfficeMaintenanceId).ToList();

            foreach (PseudoCityOrOfficeMaintenanceGDSThirdPartyVendor pseudoCityOrOfficeMaintenanceGDSThirdPartyVendor in pseudoCityOrOfficeMaintenanceGDSThirdPartyVendors)
            {
                GDSThirdPartyVendor gdsThirdPartyVendor = GetGDSThirdPartyVendor(pseudoCityOrOfficeMaintenanceGDSThirdPartyVendor.GDSThirdPartyVendorId);
                if (gdsThirdPartyVendor != null)
                {
                    gdsThirdPartyVendors.Add(gdsThirdPartyVendor);
                }
            }

            return(gdsThirdPartyVendors);
        }
        //Get GDSThirdPartyVendors
        private List <GDSThirdPartyVendor> GetGDSThirdPartyVendors(int[] gdsThirdPartyVendorIds)
        {
            List <GDSThirdPartyVendor> gdsOrderRequestTypes = new List <GDSThirdPartyVendor>();

            if (gdsThirdPartyVendorIds != null)
            {
                foreach (int gdsOrderRequestTypeId in gdsThirdPartyVendorIds)
                {
                    GDSThirdPartyVendorRepository gdsRequestTypeRepository = new GDSThirdPartyVendorRepository();
                    GDSThirdPartyVendor           gdsRequestType           = gdsRequestTypeRepository.GetGDSThirdPartyVendor(gdsOrderRequestTypeId);
                    if (gdsRequestType != null)
                    {
                        gdsOrderRequestTypes.Add(gdsRequestType);
                    }
                }
            }
            return(gdsOrderRequestTypes);
        }
        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));
        }
        public ActionResult Edit(PseudoCityOrOfficeMaintenanceVM pseudoCityOrOfficeMaintenanceVM, FormCollection formCollection)
        {
            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 <PseudoCityOrOfficeMaintenance>(pseudoCityOrOfficeMaintenanceVM.PseudoCityOrOfficeMaintenance, "PseudoCityOrOfficeMaintenance");
            }
            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"));
            }

            //ClientSubUnitGuids
            List <string> clientSubUnitGuids = new List <string>();

            foreach (string key in formCollection)
            {
                if (key.StartsWith("ClientSubUnitGuids") && !string.IsNullOrEmpty(formCollection[key]))
                {
                    clientSubUnitGuids = formCollection[key].Split(',').ToList();
                }
            }
            pseudoCityOrOfficeMaintenanceVM.ClientSubUnitGuids = clientSubUnitGuids.Distinct().ToList();

            //GDSThirdPartyVendors
            List <GDSThirdPartyVendor> gdsThirdPartyVendors = new List <GDSThirdPartyVendor>();

            foreach (string key in formCollection)
            {
                if (key.StartsWith("GDSThirdPartyVendor") && !string.IsNullOrEmpty(formCollection[key]))
                {
                    List <int> gdsThirdPartyVendorIds = formCollection[key].Split(',').Select(int.Parse).ToList();
                    foreach (int gdsThirdPartyVendorId in gdsThirdPartyVendorIds)
                    {
                        GDSThirdPartyVendorRepository gdsThirdPartyVendorRepository = new GDSThirdPartyVendorRepository();
                        GDSThirdPartyVendor           gdsThirdPartyVendor           = gdsThirdPartyVendorRepository.GetGDSThirdPartyVendor(gdsThirdPartyVendorId);
                        if (gdsThirdPartyVendor != null)
                        {
                            gdsThirdPartyVendors.Add(gdsThirdPartyVendor);
                        }
                    }
                }
            }
            pseudoCityOrOfficeMaintenanceVM.GDSThirdPartyVendors = gdsThirdPartyVendors;

            try
            {
                pseudoCityOrOfficeMaintenanceRepository.Update(pseudoCityOrOfficeMaintenanceVM);
            }
            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"));
            }

            string returnAction = (pseudoCityOrOfficeMaintenanceVM.PseudoCityOrOfficeMaintenance.DeletedFlag == true) ? "ListDeleted" : "ListUnDeleted";

            return(RedirectToAction(returnAction));
        }
 public GDSThirdPartyVendorVM(GDSThirdPartyVendor thirdPartyVendor, List <GDSThirdPartyVendorReference> thirdPartyVendorReferences)
 {
     GDSThirdPartyVendor           = thirdPartyVendor;
     GDSThirdPartyVendorReferences = thirdPartyVendorReferences;
 }