public async Task <ActionResult <Email> > CreateEmail([FromBody] CreateEmailDto email) { var exist = await _email.EmailExist(email.Email); if (exist) { return(BadRequest("Email already on the database")); } var emailToReturn = await _email.CreateEmail(email.PersonID, email.Email); var person = await _person.FindPerson(email.PersonID); var userEmail = User.FindFirst(System.Security.Claims.ClaimTypes.Email).Value; await _log.Create(userEmail, "", email.Email, $"EMAIL CREATED - {person.Name} "); return(Ok(emailToReturn)); }
public async Task <IActionResult> FindByEmail(string email) { email = email.ToLower(); var exist = await _email.EmailExist(email); if (!exist) { return(BadRequest("Email not found")); } Email firstEmail = await _email.FindEmail(email); var personID = firstEmail.PersonID; var user = await _person.FindPerson(personID); var phoneList = await _phone.FindAllUserNumber(personID); var EmailList = await _email.FindAllUserEmails(personID); var person = new PersonDto(user, phoneList, EmailList); return(Ok(person)); }