public void TestDeleteRegionAsync() { ContextSeeder.Seed(); var bo = new RegionBusinessObject(); var resList = bo.ListAsync().Result; var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result; resList = bo.ListNotDeletedAsync().Result; Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.Count == 0); }
public void TestUpdateRegionnAsync() { ContextSeeder.Seed(); var bo = new RegionBusinessObject(); var resList = bo.ListAsync().Result; var item = resList.Result.FirstOrDefault(); item.Name = "another"; var resUpdate = bo.UpdateAsync(item).Result; resList = bo.ListNotDeletedAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().Name == "another"); }
public async Task<IActionResult> Create() { var listROperation = await _rbo.ListNotDeletedAsync(); if (!listROperation.Success) return OperationErrorBackToIndex(listROperation.Exception); var rList = new List<SelectListItem>(); foreach (var item in listROperation.Result) { rList.Add(new SelectListItem() { Value = item.Id.ToString(), Text = item.Name }); } ViewBag.Regions = rList; var listCOperation = await _cbo.ListNotDeletedAsync(); if (!listCOperation.Success) return OperationErrorBackToIndex(listCOperation.Exception); var cList = new List<SelectListItem>(); foreach (var item in listCOperation.Result) { cList.Add(new SelectListItem() { Value = item.Id.ToString(), Text = item.Name }); } ViewBag.Companies = cList; Draw("Create", "fa-plus"); return View(); }
public void TestCreateSameAddressRegionAsync() { ContextSeeder.Seed(); var bo = new EstablishmentBusinessObject(); var boReg = new RegionBusinessObject(); var boComp = new CompanyBusinessObject(); var reg1 = boReg.ListNotDeletedAsync().Result.Result.First(); var com1 = boComp.ListNotDeletedAsync().Result.Result.First(); var item = bo.ListNotDeletedAsync().Result.Result.FirstOrDefault(); var est = new Establishment(item.Address, "9h00", "21h00", "monday", reg1.Id, com1.Id); var resCreate = bo.CreateAsync(est).Result; Assert.IsTrue(resCreate.Success); }
public async Task <IActionResult> Index() { var listOperation = await _bo.ListNotDeletedAsync(); if (!listOperation.Success) { return(OperationErrorBackToIndex(listOperation.Exception)); } var lst = new List <RegionViewModel>(); foreach (var item in listOperation.Result) { lst.Add(RegionViewModel.Parse(item)); } ViewData["Title"] = "Regions"; ViewData["BreadCrumbs"] = GetCrumbs(); ViewData["DeleteHref"] = GetDeleteRef(); return(View(lst)); }