public async Task<Person> AddPerson(string firstName, string lastName, string email, string registeredUserName) { var person = new Person {FirstName = firstName, LastName = lastName, Email = email, RegisteredUserName = registeredUserName}; _ctx.Persons.Add(person); var status = await _ctx.SaveChangesAsync(); return person; }
public IHttpActionResult Register(RegisterUserModel userModel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } using (var tx = new TransactionScope()) { var result = _repo.RegisterUser(new UserModel { ConfirmPassword = userModel.ConfirmPassword, Password = userModel.Password, UserName = userModel.UserName }); IHttpActionResult errorResult = GetErrorResult(result); if (errorResult != null) { return errorResult; } var user = new Person { Email = userModel.Email, FirstName = userModel.FirstName, LastName = userModel.LastName, RegisteredUserName = userModel.UserName }; _context.Persons.Add(user); _context.SaveChanges(); tx.Complete(); } return Ok(); }