Esempio n. 1
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get PolicyCarVendorGroupItem
            PolicyCarVendorGroupItem policyCarVendorGroupItem = new PolicyCarVendorGroupItem();

            policyCarVendorGroupItem = policyCarVendorGroupItemRepository.GetPolicyCarVendorGroupItem(id);

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

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

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

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

            ViewData["PolicyLocationList"] = policyLocations;

            //Populate List of PolicyCarStatuses
            PolicyCarStatusRepository policyCarStatusRepository = new PolicyCarStatusRepository();
            SelectList policyCarStatuses = new SelectList(policyCarStatusRepository.GetAllPolicyCarStatuses().ToList(), "PolicyCarStatusId", "PolicyCarStatusDescription");

            ViewData["PolicyCarStatusList"] = policyCarStatuses;

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

            ViewData["ProductList"] = products;

            //Populate new PolicyCarVendorGroupItem with known PolicyGroup Information
            PolicyGroup policyGroup = policyGroupRepository.GetGroup(policyCarVendorGroupItem.PolicyGroupId);

            policyCarVendorGroupItem.PolicyGroupName = policyGroup.PolicyGroupName;

            //return edit form
            policyCarVendorGroupItemRepository.EditItemForDisplay(policyCarVendorGroupItem);
            return(View(policyCarVendorGroupItem));
        }
Esempio n. 2
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get PolicyCarTypeGroupItem
            PolicyCarTypeGroupItem policyCarTypeGroupItem = new PolicyCarTypeGroupItem();

            policyCarTypeGroupItem = policyCarTypeGroupItemRepository.GetPolicyCarTypeGroupItem(id);

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

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

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCarTypeGroupItem.PolicyGroupId))
            {
                return(View("Error"));
            }

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

            ViewData["PolicyLocationList"] = policyLocations;

            //Populate List of PolicyCarStatuses
            PolicyCarStatusRepository policyCarStatusRepository = new PolicyCarStatusRepository();
            SelectList carStatuses = new SelectList(policyCarStatusRepository.GetAllPolicyCarStatuses().ToList(), "PolicyCarStatusId", "PolicyCarStatusDescription");

            ViewData["PolicyCarStatusList"] = carStatuses;

            //Populate List of CarTypeCategories
            CarTypeCategoryRepository carTypeCategoryRepository = new CarTypeCategoryRepository();
            SelectList carTypes = new SelectList(carTypeCategoryRepository.GetAllCarTypeCategories().ToList(), "CarTypeCategoryId", "CarTypeCategoryName");

            ViewData["CarTypeCategoryList"] = carTypes;

            //Populate new PolicyCarTypeGroupItem with known PolicyGroup Information
            PolicyGroup policyGroup = policyGroupRepository.GetGroup(policyCarTypeGroupItem.PolicyGroupId);

            policyCarTypeGroupItem.PolicyGroupName = policyGroup.PolicyGroupName;

            //Show 'Edit' Form
            policyCarTypeGroupItemRepository.EditItemForDisplay(policyCarTypeGroupItem);
            return(View(policyCarTypeGroupItem));
        }
Esempio n. 3
0
        // GET: /Create
        public ActionResult Create(int id)
        {
            PolicyGroup policyGroup = policyGroupRepository.GetGroup(id);

            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 PolicyLocations
            PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
            SelectList policyLocations = new SelectList(policyLocationRepository.GetAllPolicyLocations().ToList(), "PolicyLocationId", "PolicyLocationName");

            ViewData["PolicyLocationList"] = policyLocations;

            //Populate List of PolicyCarStatuses
            PolicyCarStatusRepository policyCarStatusRepository = new PolicyCarStatusRepository();
            SelectList carStatuses = new SelectList(policyCarStatusRepository.GetAllPolicyCarStatuses().ToList(), "PolicyCarStatusId", "PolicyCarStatusDescription");

            ViewData["PolicyCarStatusList"] = carStatuses;

            //Populate List of CarTypeCategories
            CarTypeCategoryRepository carTypeCategoryRepository = new CarTypeCategoryRepository();
            SelectList carTypes = new SelectList(carTypeCategoryRepository.GetAllCarTypeCategories().ToList(), "CarTypeCategoryId", "CarTypeCategoryName");

            ViewData["CarTypeCategoryList"] = carTypes;

            //populate new PolicyCarTypeGroupItem with known PolicyGroup Information
            PolicyCarTypeGroupItem policyCarTypeGroupItem = new PolicyCarTypeGroupItem();

            policyCarTypeGroupItem.PolicyGroupId   = id;
            policyCarTypeGroupItem.PolicyGroupName = policyGroup.PolicyGroupName;

            //Show 'Create' Form
            return(View(policyCarTypeGroupItem));
        }