Exemple #1
0
        public ActionResult Delete(int id)
        {
            //Get policySupplierServiceInformation
            PolicySupplierServiceInformation policySupplierServiceInformation = new PolicySupplierServiceInformation();

            policySupplierServiceInformation = policySupplierServiceInformationRepository.GetPolicySupplierServiceInformation(id);

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

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

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


            //populate new PolicyCarVendorGroupItem with known PolicyGroup Information
            policySupplierServiceInformationRepository.EditItemForDisplay(policySupplierServiceInformation);

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

            db.spDesktopDataAdmin_DeletePolicySupplierServiceInformation_v1(
                PolicySupplierServiceInformation.PolicySupplierServiceInformationId,
                adminUserGuid,
                PolicySupplierServiceInformation.VersionNumber
                );
        }
Exemple #3
0
        public ActionResult Create(PolicySupplierServiceInformation policySupplierServiceInformation)
        {
            PolicyGroup policyGroup = policyGroupRepository.GetGroup(policySupplierServiceInformation.PolicyGroupId);

            if (policyGroup == null)
            {
                ViewData["ActionMethod"] = "CreatePost";
                return(View("RecordDoesNotExistError"));
            }
            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

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

            //Update Model from Form
            try
            {
                UpdateModel(policySupplierServiceInformation);
            }
            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
            {
                policySupplierServiceInformationRepository.Add(policySupplierServiceInformation);
            }
            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", new { id = policySupplierServiceInformation.PolicyGroupId }));
        }
        //Add
        public void Add(PolicySupplierServiceInformation PolicySupplierServiceInformation)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_InsertPolicySupplierServiceInformation_v1(
                PolicySupplierServiceInformation.SupplierCode,
                PolicySupplierServiceInformation.PolicySupplierServiceInformationValue,
                PolicySupplierServiceInformation.ProductId,
                PolicySupplierServiceInformation.PolicySupplierServiceInformationTypeId,
                PolicySupplierServiceInformation.PolicyGroupId,
                PolicySupplierServiceInformation.EnabledFlagNonNullable,
                PolicySupplierServiceInformation.EnabledDate,
                PolicySupplierServiceInformation.ExpiryDate,
                adminUserGuid
                );
        }
Exemple #5
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            PolicySupplierServiceInformation policySupplierServiceInformation = new PolicySupplierServiceInformation();

            policySupplierServiceInformation = policySupplierServiceInformationRepository.GetPolicySupplierServiceInformation(id);

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

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

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

            //Delete Item
            try
            {
                policySupplierServiceInformation.VersionNumber = Int32.Parse(collection["VersionNumber"]);
                policySupplierServiceInformationRepository.Delete(policySupplierServiceInformation);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicySupplierServiceInformation.mvc/Delete/" + policySupplierServiceInformation.PolicySupplierServiceInformationTypeId;
                    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 = policySupplierServiceInformation.PolicyGroupId }));
        }
Exemple #6
0
        public ActionResult View(int id)
        {
            //Get policySupplierServiceInformation
            PolicySupplierServiceInformation policySupplierServiceInformation = new PolicySupplierServiceInformation();

            policySupplierServiceInformation = policySupplierServiceInformationRepository.GetPolicySupplierServiceInformation(id);

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

            policySupplierServiceInformationRepository.EditItemForDisplay(policySupplierServiceInformation);
            return(View(policySupplierServiceInformation));
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicySupplierServiceInformation policySupplierServiceInformation)
        {
            //PolicySupplierServiceInformationType
            PolicySupplierServiceInformationTypeRepository policySupplierServiceInformationTypeRepository = new PolicySupplierServiceInformationTypeRepository();
            PolicySupplierServiceInformationType           policySupplierServiceInformationType           = new PolicySupplierServiceInformationType();

            policySupplierServiceInformationType = policySupplierServiceInformationTypeRepository.GetPolicySupplierServiceInformationType(policySupplierServiceInformation.PolicySupplierServiceInformationTypeId);
            if (policySupplierServiceInformationType != null)
            {
                policySupplierServiceInformation.PolicySupplierServiceInformationTypeDescription = policySupplierServiceInformationType.PolicySupplierServiceInformationTypeDescription;
            }

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

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

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

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

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

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

            policySupplierServiceInformation.PolicyGroupName = policyGroup.PolicyGroupName;
        }
Exemple #8
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 policySupplierServiceInformationTypeRepositorys
            PolicySupplierServiceInformationTypeRepository policySupplierServiceInformationTypeRepository = new PolicySupplierServiceInformationTypeRepository();
            SelectList policySupplierServiceInformations = new SelectList(policySupplierServiceInformationTypeRepository.GetAllPolicySupplierServiceInformationTypes().ToList(), "policySupplierServiceInformationTypeId", "policySupplierServiceInformationTypeDescription");

            ViewData["PolicySupplierServiceInformationList"] = policySupplierServiceInformations;

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

            ViewData["ProductList"] = products;

            //populate new item with known PolicyGroup Information
            PolicySupplierServiceInformation policySupplierServiceInformation = new PolicySupplierServiceInformation();

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

            //Show 'Create' Form
            return(View(policySupplierServiceInformation));
        }
Exemple #9
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get policySupplierServiceInformation
            PolicySupplierServiceInformation policySupplierServiceInformation = new PolicySupplierServiceInformation();

            policySupplierServiceInformation = policySupplierServiceInformationRepository.GetPolicySupplierServiceInformation(id);

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

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

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

            //Populate List of policySupplierServiceInformationTypeRepositorys
            PolicySupplierServiceInformationTypeRepository policySupplierServiceInformationTypeRepository = new PolicySupplierServiceInformationTypeRepository();
            SelectList policySupplierServiceInformations = new SelectList(policySupplierServiceInformationTypeRepository.GetAllPolicySupplierServiceInformationTypes().ToList(), "policySupplierServiceInformationTypeId", "policySupplierServiceInformationTypeDescription");

            ViewData["policySupplierServiceInformationList"] = policySupplierServiceInformations;

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

            ViewData["ProductList"] = products;

            //return edit form
            policySupplierServiceInformationRepository.EditItemForDisplay(policySupplierServiceInformation);
            return(View(policySupplierServiceInformation));
        }
Exemple #10
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            PolicySupplierServiceInformation policySupplierServiceInformation = new PolicySupplierServiceInformation();

            policySupplierServiceInformation = policySupplierServiceInformationRepository.GetPolicySupplierServiceInformation(id);

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

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

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

            //Update policySupplierServiceInformation Model From Form
            try
            {
                UpdateModel(policySupplierServiceInformation);
            }
            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
            {
                policySupplierServiceInformationRepository.Update(policySupplierServiceInformation);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicySupplierServiceInformation.mvc/Edit/" + policySupplierServiceInformation.PolicySupplierServiceInformationId;
                    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 = policySupplierServiceInformation.PolicyGroupId }));
        }