public async Task ValidateForSave(int id, PersonForSaveDto personForCreation) { var person = await _uow.Repository <Domain.Entities.Person>().FindByIdAsync(id); AddValidationErrorIfValueIsNull(person, "Person", $"Id {id} not found"); ValidateForSave(personForCreation); }
public void ValidateForSave(PersonForSaveDto personForCreation) { Validate(personForCreation); ValidateGender(personForCreation.GenderId); ThrowValidationErrorsIfNotEmpty(); }
public async Task <IActionResult> Update(int id, PersonForSaveDto personForUpdate) { await _personValidatorService.ValidateForSave(id, personForUpdate); var person = await _personService.Update(id, personForUpdate); return(Ok(person)); }
public async Task <IActionResult> Create(PersonForSaveDto personForSave) { _personValidatorService.ValidateForSave(personForSave); var person = await _personService.Create(personForSave); return(CreatedAtRoute("GetPerson", new { controller = "Person", id = person.Id }, person)); }
public async Task <PersonForDetailedDto> Create(PersonForSaveDto personForCreation) { var person = _mapper.Map <Domain.Entities.Person>(personForCreation); _uow.Repository <Domain.Entities.Person>().Add(person); await _uow.SaveAsync(); var personToReturn = _mapper.Map <PersonForDetailedDto>(person); return(personToReturn); }
public async Task <PersonForDetailedDto> Update(int id, PersonForSaveDto personForUpdate) { var person = await _uow.Repository <Domain.Entities.Person>().FindByIdAsync(id); _mapper.Map(personForUpdate, person); await _uow.SaveAsync(); var personToReturn = _mapper.Map <PersonForDetailedDto>(person); await _photoService.IncludePhotos(personToReturn, (int)EntityTypes.Person); return(personToReturn); }