public async Task <IActionResult> PostAsync([FromBody] BusinessCreateModel model) { try { var bm = new BusinessModel { Name = model.BusinessName, Code = model.AddressPostCode, AddressStreet = model.AddressStreet, AddressCity = model.AddressCity, AddressPostCode = model.AddressPostCode, Contact1Name = model.Contact1Name, Contact1Email = model.Contact1Email, Contact1Mobile = model.Contact1Mobile, Contact2Email = model.Contact2Email, Contact2Name = model.Contact2Name, Contact2Mobile = model.Contact2Name, Status = RegistrationStatus.Submitted, BusinessTypeId = 1 }; var k = await service.InsertBusinessAsync(bm); bm.Id = k.Id; foreach (var item in model.StakeHolders) { var stk = new StakeHolderModel { BusinessId = bm.Id, SSN = item.SSN, FirstName = item.FirstName, LastName = item.FirstName, Email = item.Email, Mobile = item.Mobile, BirthDate = item.BirthDate, AddressStreet = item.AddressStreet, AddressCity = item.AddressCity, AddressPostCode = item.AddressPostCode, SeedCapital = item.SeedCapital, BankName = item.BankName, AccountNumber = item.AccountNumber }; await stakeHolderService.InsertAsync(stk); } _emailService.SendEmailAsync(model.Contact1Email, null, "Business Search", "Hello " + model.Contact1Name + ", " + "your application has been recieved by Yellow Project " + "and our person will get accross to you. Thank you!"); return(new OkResult()); } catch (Exception e) { return(BadRequest()); } }
public async Task <IActionResult> Post([FromBody] StakeHolderModel value) { try { return(Ok(await service.InsertAsync(value))); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } }