public async Task <ActionResult> ActivateOrDeactivateUser(string email) { var user = await _userManager.FindByEmailAsync(email); if (user == null) { return(NotFound()); } user.Activated = !user.Activated; var result = await _userManager.UpdateAsync(user); if (user.Activated) { if (result.Succeeded) { try { await _emailService.SendActivationEmailAsync(email); } catch (Exception ex) { // TODO: handle exception return(BadRequest(ex.Message)); // return activated but email not sent // do a quee for later ? } } else { ModelState.AddModelError("Activated", "Couldn't Update User"); return(BadRequest(new ValidationProblemDetails(ModelState))); } } return(Ok(new UserDataResponse { Name = user.Name, Activated = user.Activated, Email = user.Email, LastName = user.LastName })); }