public void TestCreateAndReadProductUnitAsync() { ContextSeeder.Seed(); var pmbo = new ProductModelBusinessObject(); var prodMod = pmbo.ListNotDeletedAsync().Result.Result.First(); var ebo = new EstablishmentBusinessObject(); var est = ebo.ListNotDeleted().Result.First(); var sbo = new ShoppingBasketBusinessObject(); var sbk = sbo.ListNotDeleted().Result.First(); var bo = new ProductUnitBusinessObject(); var prodUnit = new ProductUnit("werkyt235", false, prodMod.Id, est.Id, sbk.Id); var resCreate = bo.CreateAsync(prodUnit).Result; var resGet = bo.ReadAsync(prodUnit.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public async Task <IActionResult> Details(Guid?id) { if (id == null) { return(NotFound()); } var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var getEOperation = await _ebo.ReadAsync(getOperation.Result.EstablishmentId); if (!getEOperation.Success) { return(OperationErrorBackToIndex(getEOperation.Exception)); } if (getEOperation.Result == null) { return(RecordNotFound()); } var getSBOperation = await _sbbo.ReadAsync(getOperation.Result.ShoppingBasketId); if (!getSBOperation.Success) { return(OperationErrorBackToIndex(getSBOperation.Exception)); } if (getSBOperation.Result == null) { return(RecordNotFound()); } var getPMOperation = await _pmbo.ReadAsync(getOperation.Result.ProductModelId); if (!getPMOperation.Success) { return(OperationErrorBackToIndex(getPMOperation.Exception)); } if (getPMOperation.Result == null) { return(RecordNotFound()); } var getPOperation = await _pbo.ReadAsync(getSBOperation.Result.ProfileId); if (!getPOperation.Success) { return(OperationErrorBackToIndex(getPOperation.Exception)); } if (getPOperation.Result == null) { return(RecordNotFound()); } var getCOperation = await _cbo.ReadAsync(getEOperation.Result.CompanyId); if (!getCOperation.Success) { return(OperationErrorBackToIndex(getCOperation.Exception)); } if (getCOperation.Result == null) { return(RecordNotFound()); } var vm = ProductUnitViewModel.Parse(getOperation.Result); ViewData["Profile"] = ProfileViewModel.Parse(getPOperation.Result); ViewData["Company"] = CompanyViewModel.Parse(getCOperation.Result); ViewData["Establishment"] = EstablishmentViewModel.Parse(getEOperation.Result); ViewData["ShoppingBasket"] = ShoppingBasketViewModel.Parse(getSBOperation.Result); ViewData["ProductModel"] = ProductModelViewModel.Parse(getPMOperation.Result); Draw("Details", "fa-search"); return(View(vm)); }