// 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)); }
// 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)); }