public void TestUpdateProductUnitAsync() { ContextSeeder.Seed(); var bo = new ProductUnitBusinessObject(); var resList = bo.ListAsync().Result; var item = resList.Result.FirstOrDefault(); item.IsReserved = true; var resUpdate = bo.UpdateAsync(item).Result; resList = bo.ListNotDeletedAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().IsReserved == true); }
public async Task <IActionResult> Index() { var listOperation = await _bo.ListNotDeletedAsync(); if (!listOperation.Success) { return(OperationErrorBackToIndex(listOperation.Exception)); } var lst = new List <ProductUnitViewModel>(); foreach (var item in listOperation.Result) { lst.Add(ProductUnitViewModel.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 listSBOperation = await _sbbo.ListNotDeletedAsync(); if (!listOperation.Success) { return(OperationErrorBackToIndex(listOperation.Exception)); } var sblst = new List <ShoppingBasketViewModel>(); foreach (var item in listSBOperation.Result) { sblst.Add(ShoppingBasketViewModel.Parse(item)); } var eList = await GetEstablishmentViewModels(listOperation.Result.Select(x => x.EstablishmentId).Distinct().ToList()); var sbList = await GetShoppingBasketViewModels(listOperation.Result.Select(x => x.ShoppingBasketId).Distinct().ToList()); var pmList = await GetProductModelViewModels(listOperation.Result.Select(x => x.ProductModelId).Distinct().ToList()); var cList = await GetCompanyViewModels(listEOperation.Result.Select(x => x.CompanyId).Distinct().ToList()); var pList = await GetProfileViewModels(listSBOperation.Result.Select(x => x.ProfileId).Distinct().ToList()); ViewData["Profiles"] = pList; ViewData["Companies"] = cList; ViewData["Establishments"] = eList; ViewData["ShoppingBaskets"] = sbList; ViewData["ProductModels"] = pmList; ViewData["Title"] = "Product Units"; ViewData["BreadCrumbs"] = GetCrumbs(); ViewData["DeleteHref"] = GetDeleteRef(); return(View(lst)); }