// GET: /Edit public ActionResult Edit(int id) { //Get PolicyHotelPropertyGroupItem PolicyHotelPropertyGroupItem policyHotelPropertyGroupItem = new PolicyHotelPropertyGroupItem(); policyHotelPropertyGroupItem = policyHotelPropertyGroupItemRepository.GetPolicyHotelPropertyGroupItem(id); //Check Exists if (policyHotelPropertyGroupItem == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyHotelPropertyGroupItem.PolicyGroupId)) { return(View("Error")); } //Populate List of PolicyHotelStatuses PolicyHotelStatusRepository policyHotelStatusRepository = new PolicyHotelStatusRepository(); SelectList policyHotelStatuses = new SelectList(policyHotelStatusRepository.GetAllPolicyHotelStatuses().ToList(), "PolicyHotelStatusId", "PolicyHotelStatusDescription"); ViewData["PolicyHotelStatusList"] = policyHotelStatuses; //Populate List of HarpHotels HarpHotelRepository harpHotelRepository = new HarpHotelRepository(); SelectList harpHotels = new SelectList(harpHotelRepository.GetAllHarpHotels().ToList(), "HarpHotelId", "HarpHotelName"); ViewData["HarpHotelList"] = harpHotels; //Populate new PolicyHotelPropertyGroupItem with known PolicyGroup Information PolicyGroup policyGroup = policyGroupRepository.GetGroup(policyHotelPropertyGroupItem.PolicyGroupId); policyHotelPropertyGroupItem.PolicyGroupName = policyGroup.PolicyGroupName; //Show 'Edit' Form policyHotelPropertyGroupItemRepository.EditItemForDisplay(policyHotelPropertyGroupItem); return(View(policyHotelPropertyGroupItem)); }
// 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")); } PolicyHotelPropertyGroupItem policyHotelPropertyGroupItem = new PolicyHotelPropertyGroupItem(); //Populate List of PolicyHotelStatuses PolicyHotelStatusRepository policyHotelStatusRepository = new PolicyHotelStatusRepository(); SelectList policyHotelStatuses = new SelectList(policyHotelStatusRepository.GetAllPolicyHotelStatuses().ToList(), "PolicyHotelStatusId", "PolicyHotelStatusDescription"); ViewData["PolicyHotelStatusList"] = policyHotelStatuses; //Populate List of HarpHotels HarpHotelRepository harpHotelRepository = new HarpHotelRepository(); SelectList harpHotels = new SelectList(harpHotelRepository.GetAllHarpHotels().ToList(), "HarpHotelId", "HarpHotelName"); ViewData["HarpHotelList"] = harpHotels; //populate new PolicyHotelPropertyGroupItem with known PolicyGroup Information policyHotelPropertyGroupItem.PolicyGroupId = id; policyHotelPropertyGroupItem.PolicyGroupName = policyGroup.PolicyGroupName; //Show 'Create' Form return(View(policyHotelPropertyGroupItem)); }