示例#1
0
        public ActionResult Delete(int id)
        {
            //Get PolicySupplierDealCode
            PolicySupplierDealCode policySupplierDealCode = new PolicySupplierDealCode();

            policySupplierDealCode = policySupplierDealCodeRepository.GetPolicySupplierDealCode(id);

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

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

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policySupplierDealCode.PolicyGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Populate new PolicyCarVendorGroupItem with known PolicyGroup Information
            policySupplierDealCodeRepository.EditItemForDisplay(policySupplierDealCode);

            //Show 'Create' Form
            return(View(policySupplierDealCode));
        }
        //Add
        public void Add(PolicySupplierDealCode policySupplierDealCode)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            //PolicySupplierDealCodeOSIs to XML
            XmlDocument    doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);
            XmlElement root = doc.CreateElement("PolicySupplierDealCodeOSIs");

            doc.AppendChild(root);

            if (policySupplierDealCode.PolicySupplierDealCodeOSIs != null)
            {
                foreach (PolicySupplierDealCodeOSI policySupplierDealCodeOSI in policySupplierDealCode.PolicySupplierDealCodeOSIs)
                {
                    if (policySupplierDealCodeOSI != null)
                    {
                        if (policySupplierDealCodeOSI.PolicySupplierDealCodeOSIDescription != null && policySupplierDealCodeOSI.PolicySupplierDealCodeOSIDescription != null)
                        {
                            XmlElement xmlPolicySupplierDealCodeOSI = doc.CreateElement("PolicySupplierDealCodeOSI");

                            XmlElement xmlPolicySupplierDealCodeOSIDescription = doc.CreateElement("PolicySupplierDealCodeOSIDescription");
                            xmlPolicySupplierDealCodeOSIDescription.InnerText = policySupplierDealCodeOSI.PolicySupplierDealCodeOSIDescription;
                            xmlPolicySupplierDealCodeOSI.AppendChild(xmlPolicySupplierDealCodeOSIDescription);

                            XmlElement xmlPolicySupplierDealCodeOSISequenceNumber = doc.CreateElement("PolicySupplierDealCodeOSISequenceNumber");
                            xmlPolicySupplierDealCodeOSISequenceNumber.InnerText = policySupplierDealCodeOSI.PolicySupplierDealCodeOSISequenceNumber.ToString();
                            xmlPolicySupplierDealCodeOSI.AppendChild(xmlPolicySupplierDealCodeOSISequenceNumber);

                            root.AppendChild(xmlPolicySupplierDealCodeOSI);
                        }
                    }
                }
            }

            db.spDesktopDataAdmin_InsertPolicySupplierDealCode_v1(
                policySupplierDealCode.SupplierCode,
                policySupplierDealCode.PolicySupplierDealCodeValue,
                policySupplierDealCode.PolicySupplierDealCodeDescription,
                policySupplierDealCode.GDSCode,
                policySupplierDealCode.ProductId,
                policySupplierDealCode.PolicySupplierDealCodeTypeId,
                policySupplierDealCode.PolicyGroupId,
                policySupplierDealCode.EnabledFlagNonNullable,
                policySupplierDealCode.EnabledDate,
                policySupplierDealCode.PolicyLocationId,
                policySupplierDealCode.ExpiryDate,
                policySupplierDealCode.TravelIndicator,
                policySupplierDealCode.TourCodeTypeId,
                policySupplierDealCode.Endorsement,
                policySupplierDealCode.EndorsementOverride,
                policySupplierDealCode.OSIFlagNonNullable,
                System.Xml.Linq.XElement.Parse(doc.OuterXml),
                adminUserGuid
                );
        }
        //Delete
        public void Delete(PolicySupplierDealCode policySupplierDealCode)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeletePolicySupplierDealCode_v1(
                policySupplierDealCode.PolicySupplierDealCodeId,
                adminUserGuid,
                policySupplierDealCode.VersionNumber
                );
        }
示例#4
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            PolicySupplierDealCode policySupplierDealCode = new PolicySupplierDealCode();

            policySupplierDealCode = policySupplierDealCodeRepository.GetPolicySupplierDealCode(id);

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

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

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policySupplierDealCode.PolicyGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Delete Item
            try
            {
                policySupplierDealCode.VersionNumber = Int32.Parse(collection["VersionNumber"]);
                policySupplierDealCodeRepository.Delete(policySupplierDealCode);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicySupplierDealCode.mvc/Delete/" + policySupplierDealCode.PolicySupplierDealCodeTypeId;
                    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
            return(RedirectToAction("List", new { id = policySupplierDealCode.PolicyGroupId }));
        }
示例#5
0
        public ActionResult View(int id)
        {
            //Get PolicySupplierDealCode
            PolicySupplierDealCode policySupplierDealCode = new PolicySupplierDealCode();

            policySupplierDealCode = policySupplierDealCodeRepository.GetPolicySupplierDealCode(id);

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

            //Populate new PolicyCarVendorGroupItem with known PolicyGroup Information
            policySupplierDealCodeRepository.EditItemForDisplay(policySupplierDealCode);

            return(View(policySupplierDealCode));
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicySupplierDealCode policySupplierDealCode)
        {
            //PolicySupplierDealCodeType
            PolicySupplierDealCodeTypeRepository policySupplierDealCodeTypeRepository = new PolicySupplierDealCodeTypeRepository();
            PolicySupplierDealCodeType           policySupplierDealCodeType           = new PolicySupplierDealCodeType();

            policySupplierDealCodeType = policySupplierDealCodeTypeRepository.GetPolicySupplierDealCodeType(policySupplierDealCode.PolicySupplierDealCodeTypeId);
            if (policySupplierDealCodeType != null)
            {
                policySupplierDealCode.PolicySupplierDealCodeTypeDescription = policySupplierDealCodeType.PolicySupplierDealCodeTypeDescription;
            }

            //GDS
            GDSRepository gdsRepository = new GDSRepository();
            GDS           gds           = new GDS();

            gds = gdsRepository.GetGDS(policySupplierDealCode.GDSCode);
            if (gds != null)
            {
                policySupplierDealCode.GDSName = gds.GDSName;
            }

            //PolicyLocation
            PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
            PolicyLocation           policyLocation           = new PolicyLocation();

            policyLocation = policyLocationRepository.GetPolicyLocation((int)policySupplierDealCode.PolicyLocationId);
            if (policyLocation != null)
            {
                policySupplierDealCode.PolicyLocationName = policyLocation.PolicyLocationName;
            }

            //Supplier
            SupplierRepository supplierRepository = new SupplierRepository();
            Supplier           supplier           = new Supplier();

            supplier = supplierRepository.GetSupplier(policySupplierDealCode.SupplierCode, policySupplierDealCode.ProductId);
            if (supplier != null)
            {
                policySupplierDealCode.SupplierName = supplier.SupplierName;
            }

            //EnabledFlag is nullable
            if (policySupplierDealCode.EnabledFlag != true)
            {
                policySupplierDealCode.EnabledFlag = false;
            }
            policySupplierDealCode.EnabledFlagNonNullable = (bool)policySupplierDealCode.EnabledFlag;

            //OSIFlag is nullable
            if (policySupplierDealCode.OSIFlag != true)
            {
                policySupplierDealCode.OSIFlag = false;
            }
            policySupplierDealCode.OSIFlagNonNullable = (bool)policySupplierDealCode.OSIFlag;

            //Product
            ProductRepository productRepository = new ProductRepository();
            Product           product           = new Product();

            product = productRepository.GetProduct(policySupplierDealCode.ProductId);
            if (product != null)
            {
                policySupplierDealCode.ProductName = product.ProductName;
            }

            //PolicyGroup
            PolicyGroupRepository policyGroupRepository = new PolicyGroupRepository();
            PolicyGroup           policyGroup           = policyGroupRepository.GetGroup(policySupplierDealCode.PolicyGroupId);

            policySupplierDealCode.PolicyGroupName = policyGroup.PolicyGroupName;

            //Tour Code Type
            TourCodeTypeRepository tourCodeTypeRepository = new TourCodeTypeRepository();
            TourCodeType           tourCodeType           = tourCodeTypeRepository.GetTourCodeType(policySupplierDealCode.TourCodeTypeId ?? 0);

            if (tourCodeType != null)
            {
                policySupplierDealCode.TourCodeType = tourCodeType;
            }
        }
示例#7
0
        // GET: /Create
        public ActionResult Create(int id)
        {
            PolicyGroup policyGroup = policyGroupRepository.GetGroup(id);

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

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

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

            //Populate List of GDSs
            GDSRepository gdsRepository = new GDSRepository();
            SelectList    gdss          = new SelectList(gdsRepository.GetAllGDSs().ToList(), "GDSCode", "GDSName");

            ViewData["GDSList"] = gdss;

            //Populate List of PolicySupplierDealCodeTypes
            PolicySupplierDealCodeTypeRepository policySupplierDealCodeType = new PolicySupplierDealCodeTypeRepository();
            SelectList policySupplierDealCodeTypes = new SelectList(policySupplierDealCodeType.GetAllPolicySupplierDealCodeTypes().ToList(), "PolicySupplierDealCodeTypeId", "PolicySupplierDealCodeTypeDescription");

            ViewData["PolicySupplierDealCodeTypeList"] = policySupplierDealCodeTypes;

            //Populate List of Products
            ProductRepository productRepository = new ProductRepository();
            SelectList        products          = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName");

            ViewData["ProductList"] = products;

            //Populate List of Policy Locations
            PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
            SelectList policyLocations = new SelectList(policyLocationRepository.GetAllPolicyLocations().ToList(), "PolicyLocationId", "PolicyLocationName");

            ViewData["PolicyLocationList"] = policyLocations;

            //Populate List of Travel Indicators
            TravelIndicatorRepository travelIndicatorRepository = new TravelIndicatorRepository();
            SelectList travelIndicators = new SelectList(travelIndicatorRepository.GetAllTravelIndicators().ToList(), "TravelIndicator1", "TravelIndicatorDescription");

            ViewData["TravelIndicatorList"] = travelIndicators;

            //Populate Blank List of Tour Code Types (Chosen with GDS Selection)
            TourCodeTypeRepository tourCodeTypeRepository = new TourCodeTypeRepository();
            List <TourCodeType>    defaultList            = new List <TourCodeType>();
            SelectList             tourCodeTypes          = new SelectList(defaultList, "TourCodeTypeId", "TourCodeTypeDescription");

            ViewData["TourCodeTypeList"] = tourCodeTypes;

            //populate new item with known PolicyGroup Information
            PolicySupplierDealCode policySupplierDealCode = new PolicySupplierDealCode();

            policySupplierDealCode.PolicyGroupId          = id;
            policySupplierDealCode.PolicyGroupName        = policyGroup.PolicyGroupName;
            policySupplierDealCode.EnabledFlagNonNullable = true;

            //Show 'Create' Form
            return(View(policySupplierDealCode));
        }
示例#8
0
        public ActionResult Edit(PolicySupplierDealCode policySupplierDealCode, FormCollection formCollection)
        {
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policySupplierDealCode.PolicyGroupId);

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

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

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policySupplierDealCode.PolicyGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Create PolicySupplierDealCodeOSIs from Post values
            System.Data.Linq.EntitySet <PolicySupplierDealCodeOSI> PolicySupplierDealCodeOSIs = new System.Data.Linq.EntitySet <PolicySupplierDealCodeOSI>();

            foreach (string key in formCollection)
            {
                if (key.StartsWith("PolicySupplierDealCodeOSI") && !string.IsNullOrEmpty(formCollection[key]))
                {
                    PolicySupplierDealCodeOSI policySupplierDealCodeOSI = new PolicySupplierDealCodeOSI()
                    {
                        PolicySupplierDealCodeOSIDescription    = formCollection[key],
                        PolicySupplierDealCodeOSISequenceNumber = int.Parse(key.Replace("PolicySupplierDealCodeOSI_", ""))
                    };

                    PolicySupplierDealCodeOSIs.Add(policySupplierDealCodeOSI);
                }
            }

            if (PolicySupplierDealCodeOSIs != null && PolicySupplierDealCodeOSIs.Count > 0)
            {
                policySupplierDealCode.PolicySupplierDealCodeOSIs = PolicySupplierDealCodeOSIs;
            }

            //Update PolicySupplierDealCode Model From Form
            try
            {
                UpdateModel(policySupplierDealCode, "PolicySupplierDealCode");
            }
            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"));
            }

            //Database Update
            try
            {
                policySupplierDealCodeRepository.Update(policySupplierDealCode);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicySupplierDealCode.mvc/Edit/" + policySupplierDealCode.PolicySupplierDealCodeId;
                    return(View("VersionError"));
                }

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

            //Return to Form
            return(RedirectToAction("List", new { id = policySupplierDealCode.PolicyGroupId }));
        }
示例#9
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get PolicySupplierDealCode
            PolicySupplierDealCode policySupplierDealCode = new PolicySupplierDealCode();

            policySupplierDealCode = policySupplierDealCodeRepository.GetPolicySupplierDealCode(id);

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

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

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policySupplierDealCode.PolicyGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Populate List of GDSs
            GDSRepository gdsRepository = new GDSRepository();
            SelectList    gdss          = new SelectList(gdsRepository.GetAllGDSs().ToList(), "GDSCode", "GDSName");

            ViewData["GDSList"] = gdss;

            //Populate List of Products
            ProductRepository productRepository = new ProductRepository();
            SelectList        products          = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName");

            ViewData["ProductList"] = products;

            //Populate List of PolicySupplierDealCodeTypes
            PolicySupplierDealCodeTypeRepository policySupplierDealCodeType = new PolicySupplierDealCodeTypeRepository();
            SelectList policySupplierDealCodeTypes = new SelectList(policySupplierDealCodeType.GetAllPolicySupplierDealCodeTypes().ToList(), "PolicySupplierDealCodeTypeId", "PolicySupplierDealCodeTypeDescription");

            ViewData["PolicySupplierDealCodeTypeList"] = policySupplierDealCodeTypes;

            //Populate List of Policy Locations
            PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
            SelectList policyLocations = new SelectList(policyLocationRepository.GetAllPolicyLocations().ToList(), "PolicyLocationId", "PolicyLocationName");

            ViewData["PolicyLocationList"] = policyLocations;

            //Populate List of Travel Indicators
            TravelIndicatorRepository travelIndicatorRepository = new TravelIndicatorRepository();
            SelectList travelIndicators = new SelectList(travelIndicatorRepository.GetAllTravelIndicators().ToList(), "TravelIndicator1", "TravelIndicatorDescription", policySupplierDealCode.TravelIndicator);

            ViewData["TravelIndicatorList"] = travelIndicators;

            //Populate List of Tour Code Types
            TourCodeTypeRepository tourCodeTypeRepository = new TourCodeTypeRepository();
            SelectList             tourCodeTypes          = new SelectList(tourCodeTypeRepository.GetTourCodeTypesForGDS(policySupplierDealCode.GDSCode).ToList(), "TourCodeTypeId", "TourCodeTypeDescription", policySupplierDealCode.TourCodeTypeId);

            ViewData["TourCodeTypeList"] = tourCodeTypes;

            //return edit form
            policySupplierDealCodeRepository.EditItemForDisplay(policySupplierDealCode);
            return(View(policySupplierDealCode));
        }