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 = ProposalVM.Parse(getOperation.Result); var listJobOperation = await _jobBO.ListUndeletedAsync(); if (!listJobOperation.Success) { return(OperationErrorBackToIndex(listJobOperation.Exception)); } var jobList = new List <SelectListItem>(); foreach (var item in listJobOperation.Result) { var listItem = new SelectListItem() { Value = item.Id.ToString(), Text = (item.Address + " -- STARTING @ " + item.StartDate) }; if (item.Id == vm.JobId) { listItem.Selected = true; } jobList.Add(listItem); } ViewBag.Jobs = jobList; var crumbs = GetCrumbs(); crumbs.Add(new BreadCrumb() { Action = "Edit", Controller = "Proposals", Icon = "fa-edit", Text = "Edit" }); ViewData["Title"] = "Edit proposal"; 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 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 = ProposalVM.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 <ProposalVM>(); foreach (var item in list) { var vm = ProposalVM.Parse(item); finalList.Add(vm); } return(Ok(finalList)); }
public async Task <IActionResult> Index() { var listOperation = await _bo.ListUndeletedAsync(); if (!listOperation.Success) { return(OperationErrorBackToIndex(listOperation.Exception)); } var finalList = new List <ProposalVM>(); foreach (var item in listOperation.Result) { finalList.Add(ProposalVM.Parse(item)); } var jobList = await GetJobViewModels(listOperation.Result.Select(x => x.JobId).Distinct().ToList()); ViewData["Title"] = "Proposals"; ViewData["Jobs"] = jobList; ViewData["BreadCrumbs"] = GetCrumbs(); ViewData["DeleteHref"] = GetDeleteRef(); return(View(finalList)); }