public async Task <IActionResult> Index() { var listOperation = await _bo.ListUndeletedAsync(); if (!listOperation.Success) { return(OperationErrorBackToIndex(listOperation.Exception)); } var finalList = new List <JobVM>(); foreach (var item in listOperation.Result) { finalList.Add(JobVM.Parse(item)); } var serviceList = await GetServiceViewModels(listOperation.Result.Select(x => x.ServiceId).Distinct().ToList()); var clientList = await GetClientViewModels(listOperation.Result.Select(x => x.ClientId).Distinct().ToList()); ViewData["Title"] = "Jobs"; ViewData["Services"] = serviceList; ViewData["Clients"] = clientList; ViewData["BreadCrumbs"] = GetCrumbs(); ViewData["DeleteHref"] = GetDeleteRef(); return(View(finalList)); }
public async Task <IActionResult> Edit(Guid?id) { if (id == null) { return(RecordNotFound()); } var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var vm = JobVM.Parse(getOperation.Result); var listClientOperation = await _clientBO.ListUndeletedAsync(); if (!listClientOperation.Success) { return(OperationErrorBackToIndex(listClientOperation.Exception)); } var clientList = new List <SelectListItem>(); foreach (var item in listClientOperation.Result) { var clientName = await _clientBO.ReadAsync(item.Id); var listItem = new SelectListItem() { Value = item.Id.ToString(), Text = (clientName.Result.FullName + " -- " + clientName.Result.Country) }; if (item.Id == vm.ClientId) { listItem.Selected = true; } clientList.Add(listItem); } ViewBag.Clients = clientList; var crumbs = GetCrumbs(); crumbs.Add(new BreadCrumb() { Action = "Edit", Controller = "Jobs", Icon = "fa-edit", Text = "Edit" }); ViewData["Title"] = "Edit job"; ViewData["BreadCrumbs"] = crumbs; return(View(vm)); }
public async Task <IActionResult> Details(Guid?id) { if (id == null) { return(RecordNotFound()); } var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var getServiceOperation = await _serviceBO.ReadAsync(getOperation.Result.ServiceId); if (!getServiceOperation.Success) { return(OperationErrorBackToIndex(getServiceOperation.Exception)); } if (getServiceOperation.Result == null) { return(RecordNotFound()); } var getClientOperation = await _clientBO.ReadAsync(getOperation.Result.ClientId); if (!getClientOperation.Success) { return(OperationErrorBackToIndex(getClientOperation.Exception)); } if (getClientOperation.Result == null) { return(RecordNotFound()); } var vm = JobVM.Parse(getOperation.Result); var crumbs = GetCrumbs(); crumbs.Add(new BreadCrumb() { Action = "Details", Controller = "Jobs", Icon = "fa-info-circle", Text = "Details" }); ViewData["Title"] = "Job details"; ViewData["BreadCrumbs"] = crumbs; ViewData["Service"] = ServiceVM.Parse(getServiceOperation.Result); ViewData["Client"] = ClientVM.Parse(getClientOperation.Result); return(View(vm)); }
private async Task <List <JobVM> > GetJobViewModels(List <Guid> ids) { var filterOperation = await _jobBO.FilterAsync(x => ids.Contains(x.Id)); var jobList = new List <JobVM>(); foreach (var item in filterOperation.Result) { jobList.Add(JobVM.Parse(item)); } return(jobList); }
public async Task <IActionResult> Details(Guid?id) { if (id == null) { return(RecordNotFound()); } var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var getJobOperation = await _jobBO.ReadAsync(getOperation.Result.JobId); if (!getJobOperation.Success) { return(OperationErrorBackToIndex(getJobOperation.Exception)); } if (getJobOperation.Result == null) { return(RecordNotFound()); } var vm = ProposalVM.Parse(getOperation.Result); var crumbs = GetCrumbs(); crumbs.Add(new BreadCrumb() { Action = "Details", Controller = "Proposals", Icon = "fa-info-circle", Text = "Details" }); ViewData["Title"] = "Proposal details"; ViewData["BreadCrumbs"] = crumbs; ViewData["Job"] = JobVM.Parse(getJobOperation.Result); return(View(vm)); }
public async Task <IActionResult> GetAsync(Guid id) { var getResult = await _bo.ReadAsync(id); if (!getResult.Success) { return(InternalServerError(getResult.Exception)); } var item = getResult.Result; if (item == null) { return(NotFound()); } var vm = JobVM.Parse(item); return(Ok(vm)); }
public async Task <IActionResult> ListAsync() { var listResult = await _bo.ListUndeletedAsync(); if (!listResult.Success) { return(InternalServerError(listResult.Exception)); } var list = listResult.Result; var finalList = new List <JobVM>(); foreach (var item in list) { var vm = JobVM.Parse(item); finalList.Add(vm); } return(Ok(finalList)); }
private async Task <JobVM> GetJobViewModel(Guid id) { var getOperation = await _jobBO.ReadAsync(id); return(JobVM.Parse(getOperation.Result)); }