public async Task <IHttpActionResult> SetUserEmployer(OrganizationMembership organizationMembership) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_employerService.ValidateEmployer(organizationMembership.Employer)) { BadRequest("Employer is not validate."); } var responseMessage = Request.CreateResponse(HttpStatusCode.OK); // determine the uniqueness of the employer var employer = _employerService.FindExistingEmployer(organizationMembership.Employer); if (employer == null) { var userIdentity = ((ClaimsIdentity)User.Identity); var userId = userIdentity.GetUserId(); var user = UserManager.Users.SingleOrDefault(s => s.Id == userId && s.Deleted != true && s.Disabled != true); // set user organization user.Organizations.Add(organizationMembership); IdentityResult result = await UserManager.UpdateAsync(user); if (!result.Succeeded) { return(GetErrorResult(result)); } } else { // Employer exists var orgMembership = _organizationService.GetOrganizationMembershipByEmployer(employer); responseMessage.StatusCode = HttpStatusCode.Found; responseMessage.Content = new StringContent(string.Format("{0} {1}", orgMembership?.CreatedBy?.FirstName, orgMembership?.CreatedBy?.LastName)); } return(ResponseMessage(responseMessage)); }