public async Task <IHttpActionResult> Register_Company(RegisterCompany model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = new ApplicationUser() { UserName = model.Email, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { var UserId = UserManager.FindByEmail(model.Email); CompanyProvider.SaveCompanyInfo(model, UserId.Id); CompanyProvider.SaveCategory(model, UserId.Id); UserManager.AddToRole(UserId.Id, "Company"); } if (!result.Succeeded) { return(GetErrorResult(result)); } return(Ok()); }