public void TestCreateAndReadCompanyAsync() { ContextSeeder.Seed(); var bo = new CompanyBusinessObject(); var reg = new Company("Sonae", 1823445); var resCreate = bo.CreateAsync(reg).Result; var resGet = bo.ReadAsync(reg.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestCreateSameVatNumberCompanyAsync() { ContextSeeder.Seed(); var bo = new CompanyBusinessObject(); var item = bo.ListNotDeletedAsync().Result.Result.First(); var est = new Company("Ilhas", item.VatNumber); var resCreate = bo.CreateAsync(est).Result; Assert.IsTrue(resCreate.Success); }
public void TestCreateCompanyAsync() { BoraNowSeeder.Seed(); var cbo = new CompanyBusinessObject(); var pbo = new ProfileBusinessObject(); var profile = new Profile("EE", "AA"); pbo.Create(profile); var company = new Company("B", "C", "123", "234", profile.Id); var resCreate = cbo.CreateAsync(company).Result; var resGet = cbo.ReadAsync(company.Id).Result; Assert.IsTrue(resGet.Success && resCreate.Success && resGet.Result != null); }
public async Task <IActionResult> Create([Bind("Name, Representative, PhoneNumber, VatNumber, ProfileId")] CompanyViewModel vm) { if (ModelState.IsValid) { var c = vm.ToCompany(); var createOperation = await _bo.CreateAsync(c); if (!createOperation.Success) { return(OperationErrorBackToIndex(createOperation.Exception)); } else { return(OperationSuccess("The company account was successfuly registered!")); } } return(View(vm)); }
public async Task <IActionResult> Create(CompanyViewModel 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)); }