public async Task <IHttpActionResult> EditEmail(int userID, string oldEmail, string newEmail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (string.IsNullOrWhiteSpace(newEmail)) { return(BadRequest()); } if (string.IsNullOrWhiteSpace(oldEmail)) { return(NotFound()); } User user = await Task.Run(() => db.Users.Where((u) => u.Email.ToLower() == oldEmail.ToLower() && u.UserID == userID).FirstOrDefault()); if (user == null) { return(NotFound()); } await db.EditUserEmail(oldEmail, newEmail); return(Ok()); }