public async Task <PersonPhoneResponse> FindAsync(string key) { try { var result = await _personPhoneService.FindAsync(key); var response = new PersonPhoneResponse { PersonPhoneObjects = new List <PersonPhoneDto>() }; response.PersonPhoneObjects.Add(_mapper.Map <PersonPhoneDto>(result)); return(response); } catch (System.Exception ex) { return(new PersonPhoneResponse { Success = false, Errors = new List <object> { ex.Message } }); } }
public async Task <PersonPhoneResponse> UpdatePersonPhone(int id, PersonPhoneDto personPhone) { var person = await _personService.Find(personPhone.PersonId); var personPhoneUpdate = await _personPhoneService.Find(id); personPhoneUpdate.PhoneNumber = personPhone.PhoneNumber; personPhoneUpdate.PhoneNumberType = await _phoneNumberTypeService.Find(x => x.Name == personPhone.PhoneNumberType); personPhoneUpdate.Person = person; await _personPhoneService.Update(personPhoneUpdate); var response = new PersonPhoneResponse { PersonPhoneObject = new PersonPhoneDto { BusinessEntityID = personPhoneUpdate.BusinessEntityID, PersonId = personPhoneUpdate.Person.BusinessEntityID, PhoneNumber = personPhoneUpdate.PhoneNumber, PhoneNumberType = personPhoneUpdate.PhoneNumberType.Name } }; return(response); }
public async Task <PersonPhoneResponse> AddPersonPhone(PersonPhoneDto personPhone) { var person = await _personService.Find(personPhone.PersonId); var newPersonPhone = new PersonPhone { PhoneNumber = personPhone.PhoneNumber, PhoneNumberType = await _phoneNumberTypeService.Find(x => x.Name == personPhone.PhoneNumberType), Person = person }; await _personPhoneService.Add(newPersonPhone); var response = new PersonPhoneResponse { PersonPhoneObject = new PersonPhoneDto { BusinessEntityID = newPersonPhone.BusinessEntityID, PersonId = newPersonPhone.Person.BusinessEntityID, PhoneNumber = newPersonPhone.PhoneNumber, PhoneNumberType = newPersonPhone.PhoneNumberType.Name } }; return(response); }
public async Task <PersonPhoneResponse> PutAsync(PersonPhoneRequest person) { var result = await _personPhoneService.PutAsync(_mapper.Map <PersonPhone>(person)); var response = new PersonPhoneResponse(); response.PersonPhoneObject = _mapper.Map <PersonPhoneDto>(result); return(response); }
public async Task <PersonPhoneResponse> Delete(int id) { var personPhoneResponse = await _personPhoneService.Delete(id); var response = new PersonPhoneResponse(); response.PersonPhoneObject = new PersonPhoneDto(); response.PersonPhoneObject = _mapper.Map <PersonPhone, PersonPhoneDto>(personPhoneResponse); return(response); }
public async Task <PersonPhoneResponse> FindAllByIdAsync(int businessEntityID) { var result = await _personPhoneService.FindAllByIdAsync(businessEntityID); var response = new PersonPhoneResponse(); response.PersonPhoneObjects = new List <PersonPhoneDto>(); response.PersonPhoneObjects.AddRange(result.Select(x => _mapper.Map <PersonPhoneDto>(x))); return(response); }
public async Task <PersonPhoneResponse> Update(PersonPhoneDto personPhoneDto) { var personPhone = _mapper.Map <PersonPhoneDto, PersonPhone>(personPhoneDto); var personPhoneResponse = await _personPhoneService.Update(personPhone); var response = new PersonPhoneResponse(); response.PersonPhoneObject = new PersonPhoneDto(); response.PersonPhoneObject = _mapper.Map <PersonPhone, PersonPhoneDto>(personPhoneResponse); return(response); }
public async Task <PersonPhoneResponse> FindAllAsync() { var result = await personPhoneService.FindAllAsync(); var response = new PersonPhoneResponse(); response.PersonPhoneObjects = new List <Dtos.PersonPhoneDto>(); response.PersonPhoneObjects.AddRange(result.Select(x => mapper.Map <PersonPhoneDto>(x))); return(response); }
public async Task <PersonPhoneResponse> FindByIdAsync(int id) { var result = await personPhoneService.FindById(id); var response = new PersonPhoneResponse(); response.PersonPhoneObjects = new List <PersonPhoneDto>(); response.PersonPhoneObjects.Add(mapper.Map <PersonPhoneDto>(result)); return(response); }
public async Task <PersonPhoneResponse> RemovePersonPhone(PersonPhoneRequest request) { request.PersonPhone.PhoneNumberType = null; var result = await personPhoneService.RemovePersonPhone(mapper.Map <PersonPhone>(request.PersonPhone)); var response = new PersonPhoneResponse(); response.Success = result; return(response); }
public async Task <PersonPhoneResponse> EditPersonPhone(PersonPhoneRequest request) { var result = await personPhoneService.EditPersonPhone(mapper.Map <PersonPhone>(request.PersonPhone), mapper.Map <PersonPhone>(request.Extra)); var response = new PersonPhoneResponse(); response.PersonPhoneObjects.Add(result ? request.PersonPhone : null); response.Success = result; return(response); }
public async Task <PersonPhoneResponse> FindPersonPhone(int id) { var result = await _personPhoneService.Find(id); var response = new PersonPhoneResponse { PersonPhoneObject = new PersonPhoneDto { BusinessEntityID = result.BusinessEntityID, PersonId = result.Person.BusinessEntityID, PhoneNumber = result.PhoneNumber, PhoneNumberType = result.PhoneNumberType.Name } }; return(response); }
public PersonPhoneResponse SelectAllPersonPhone() { var response = new PersonPhoneResponse(); try { var result = _personPhoneService.SelectAllPersonPhone(); response.Success = true; response.PersonObjects = result; } catch (Exception ex) { response.Success = false; response.Errors.Add(ex); } return(response); }
public async Task <PersonPhoneResponse> RemovePersonPhone(int id) { var removedPersonPhone = await _personPhoneService.Find(x => x.BusinessEntityID == id); var response = new PersonPhoneResponse { PersonPhoneObject = new PersonPhoneDto { BusinessEntityID = removedPersonPhone.BusinessEntityID, PersonId = removedPersonPhone.Person.BusinessEntityID, PhoneNumber = removedPersonPhone.PhoneNumber, PhoneNumberType = removedPersonPhone.PhoneNumberType.Name } }; await _personPhoneService.Remove(removedPersonPhone); return(response); }
public PersonPhoneResponse SelectPersonPhone(string phoneNumber) { var request = new PersonPhoneResponseDto() { PhoneNumber = phoneNumber, }; var response = new PersonPhoneResponse(); try { var result = _personPhoneService.SelectPersonPhone(request); response.Success = true; response.PersonObjects = result; } catch (Exception ex) { response.Success = false; response.Errors.Add(ex); } return(response); }
public PersonPhoneResponse DeletePersonPhone(int personId, int typePhoneId, string phoneNumber) { var request = new PersonPhone() { BusinessEntityID = personId, PhoneNumber = phoneNumber, PhoneNumberTypeID = typePhoneId }; var response = new PersonPhoneResponse(); try { var result = _personPhoneService.DeletePersonPhone(request); response.Success = result; } catch (Exception ex) { response.Success = false; response.Errors.Add(ex); } return(response); }
public PersonPhoneResponse UpdatePersonPhone(PersonPhoneResponseDto objReq, string newPhoneNumber) { var request = new PersonPhone() { BusinessEntityID = objReq.BusinessEntityID, PhoneNumber = objReq.PhoneNumber, PhoneNumberTypeID = objReq.PhoneNumberTypeID, }; var response = new PersonPhoneResponse(); try { var result = _personPhoneService.UpdatePersonPhone(request, newPhoneNumber); response.Success = result; } catch (Exception ex) { response.Success = false; response.Errors.Add(ex); } return(response); }