public async Task <IActionResult> Create([Bind("FirstName, LastName, BirthDate, Gender, ProfileId, CountryId")] VisitorViewModel vm) { if (ModelState.IsValid) { var Visitor = vm.ToVisitor(); var createOperation = await _bo.CreateAsync(Visitor); if (!createOperation.Success) { return(OperationErrorBackToIndex(createOperation.Exception)); } return(OperationSuccess("The visitor account was successfuly registered!")); } return(View(vm)); }
public void TestCreateVisitorAsync() { BoraNowSeeder.Seed(); var vbo = new VisitorBusinessObject(); var countrybo = new CountryBusinessObject(); var pbo = new ProfileBusinessObject(); var companybo = new CompanyBusinessObject(); var country = new Country("Holanda"); var profile = new Profile("a", "b"); var company = new Company("a", "b", "c", "d", profile.Id); countrybo.Create(country); pbo.Create(profile); companybo.Create(company); var visitor = new Visitor("m", "f", DateTime.Now.AddYears(-24), "m", profile.Id, country.Id); var resCreate = vbo.CreateAsync(visitor).Result; var restGet = vbo.ReadAsync(visitor.Id).Result; Assert.IsTrue(resCreate.Success && restGet.Success && restGet.Result != null); }