public async Task <IActionResult> Create(BrandViewModel vm) { if (ModelState.IsValid) { var model = vm.ToModel(); var createOperation = await _bo.CreateAsync(model); if (!createOperation.Success) { return(OperationErrorBackToIndex(createOperation.Exception)); } if (!createOperation.Result) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, createOperation.Message); Draw("Create", "fa-plus"); return(View()); } else { return(OperationSuccess("The record was successfuly created")); } } return(View(vm)); }
public void TestCreateAndReadBrandAsync() { ContextSeeder.Seed(); var bo = new BrandBusinessObject(); var reg = new Brand("Dona Ermelinda"); var resCreate = bo.CreateAsync(reg).Result; var resGet = bo.ReadAsync(reg.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestCreateSameNameBrandAsync() { ContextSeeder.Seed(); var bo = new BrandBusinessObject(); var item = bo.ListAsync().Result.Result.FirstOrDefault(); var reg = new Brand(item.Name); var resCreate = bo.CreateAsync(reg).Result; Assert.IsTrue(!resCreate.Result); }