public ActionResult <List <StoreQueueViewModel> > List() { var res = _bo.List(); if (!res.Success) { return(InternalServerError()); } var list = new List <StoreQueueViewModel>(); foreach (var item in res.Result) { list.Add(StoreQueueViewModel.Parse(item)); } return(list); }
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 getDrOperation = await _ebo.ReadAsync(getOperation.Result.EstablishmentId); if (!getDrOperation.Success) { return(OperationErrorBackToIndex(getDrOperation.Exception)); } if (getDrOperation.Result == null) { return(RecordNotFound()); } var getCOperation = await _cbo.ReadAsync(getDrOperation.Result.CompanyId); if (!getCOperation.Success) { return(OperationErrorBackToIndex(getCOperation.Exception)); } if (getCOperation.Result == null) { return(RecordNotFound()); } var vm = StoreQueueViewModel.Parse(getOperation.Result); ViewData["Company"] = CompanyViewModel.Parse(getCOperation.Result); ViewData["Establishment"] = EstablishmentViewModel.Parse(getDrOperation.Result); Draw("Details", "fa-search"); return(View(vm)); }
public ActionResult <StoreQueueViewModel> Get(Guid id) { var res = _bo.Read(id); if (res.Success) { if (res.Result == null) { return(NotFound()); } var vm = StoreQueueViewModel.Parse(res.Result); return(vm); } else { return(InternalServerError()); } }
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 = StoreQueueViewModel.Parse(getOperation.Result); var listDrOperation = await _ebo.ListNotDeletedAsync(); if (!listDrOperation.Success) { return(OperationErrorBackToIndex(listDrOperation.Exception)); } var drList = new List <SelectListItem>(); foreach (var item in listDrOperation.Result) { var listItem = new SelectListItem() { Value = item.Id.ToString(), Text = item.Address }; if (item.Id == vm.EstablishmentId) { listItem.Selected = true; } drList.Add(listItem); } ViewBag.Establishments = drList; Draw("Edit", "fa-edit"); return(View(vm)); }
public async Task <IActionResult> Index() { var listOperation = await _bo.ListNotDeletedAsync(); if (!listOperation.Success) { return(OperationErrorBackToIndex(listOperation.Exception)); } var lst = new List <StoreQueueViewModel>(); foreach (var item in listOperation.Result) { lst.Add(StoreQueueViewModel.Parse(item)); } var listEOperation = await _ebo.ListNotDeletedAsync(); if (!listOperation.Success) { return(OperationErrorBackToIndex(listOperation.Exception)); } var elst = new List <EstablishmentViewModel>(); foreach (var item in listEOperation.Result) { elst.Add(EstablishmentViewModel.Parse(item)); } var drList = await GetEstablishmentViewModels(listOperation.Result.Select(x => x.EstablishmentId).Distinct().ToList()); var cList = await GetCompanyViewModels(listEOperation.Result.Select(x => x.CompanyId).Distinct().ToList()); ViewData["Companies"] = cList; ViewData["Establishments"] = drList; ViewData["Title"] = "Store Queues"; ViewData["BreadCrumbs"] = GetCrumbs(); ViewData["DeleteHref"] = GetDeleteRef(); return(View(lst)); }