// GET: /Edit public ActionResult Edit(int id) { ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(id); //Check Exists if (clientDetail == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } clientDetailRepository.EditGroupForDisplay(clientDetail); string csu = clientDetail.ClientSubUnitGuid; string tt = clientDetail.TravelerTypeGuid; ClientSubUnitTravelerType clientSubUnitTravelerType = new ClientSubUnitTravelerType(); clientSubUnitTravelerType = clientSubUnitTravelerTypeRepository.GetClientSubUnitTravelerType(csu, tt); //Check Exists if (clientSubUnitTravelerType == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnit(csu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientSubUnitTravelerTypeClientDetailVM clientSubUnitTravelerTypeClientDetailVM = new ClientSubUnitTravelerTypeClientDetailVM(); clientSubUnitTravelerTypeClientDetailVM.ClientDetail = clientDetail; TripTypeRepository tripTypeRepository = new TripTypeRepository(); clientSubUnitTravelerTypeClientDetailVM.TripTypes = new SelectList(tripTypeRepository.GetAllTripTypes().ToList(), "TripTypeId", "TripTypeDescription", clientDetail.TripTypeId); ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); clientSubUnitTravelerTypeClientDetailVM.ClientSubUnit = clientSubUnit; TravelerType travelerType = new TravelerType(); travelerType = travelerTypeRepository.GetTravelerType(tt); clientSubUnitTravelerTypeClientDetailVM.TravelerType = travelerType; return(View(clientSubUnitTravelerTypeClientDetailVM)); }
// GET: /Edit public ActionResult Edit(int id) { ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(id); //Check Exists if (clientDetail == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } clientDetailRepository.EditGroupForDisplay(clientDetail); string can = clientDetail.HierarchyCode; string ssc = clientDetail.SourceSystemCode; //Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } ClientAccountClientDetailVM clientAccountClientDetailVM = new ClientAccountClientDetailVM(); clientAccountClientDetailVM.ClientDetail = clientDetail; TripTypeRepository tripTypeRepository = new TripTypeRepository(); clientAccountClientDetailVM.TripTypes = new SelectList(tripTypeRepository.GetAllTripTypes().ToList(), "TripTypeId", "TripTypeDescription", clientDetail.TripTypeId); ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); clientAccountClientDetailVM.ClientAccount = clientAccount; return(View(clientAccountClientDetailVM)); }
public ActionResult Delete(string csu, string tt, int id) { //always use this ClientDetailTravelerType clientDetailTravelerType = new ClientDetailTravelerType(); clientDetailTravelerType = clientDetailTravelerTypeRepository.GetClientDetailTravelerType(id); //Check Exists if (clientDetailTravelerType == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } ClientSubUnitTravelerType clientSubUnitTravelerType = new ClientSubUnitTravelerType(); clientSubUnitTravelerType = clientSubUnitTravelerTypeRepository.GetClientSubUnitTravelerType(csu, tt); //Check Exists if (clientSubUnitTravelerType == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Get Item ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(id); //Check Exists if (clientDetail == null || clientDetail.DeletedFlag == true) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToClientSubUnit(csu)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } TravelerTypeClientDetailVM travelerTypeClientDetailVM = new TravelerTypeClientDetailVM(); clientDetailRepository.EditGroupForDisplay(clientDetail); travelerTypeClientDetailVM.ClientDetail = clientDetail; ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(csu); travelerTypeClientDetailVM.ClientSubUnit = clientSubUnit; TravelerType travelerType = new TravelerType(); travelerType = travelerTypeRepository.GetTravelerType(tt); travelerTypeClientDetailVM.TravelerType = travelerType; return(View(travelerTypeClientDetailVM)); }