public IActionResult EditPersonalInfo(long id, [FromBody] EditPersonalInfoRequest request) { Student student = _studentRepository.GetById(id); student.EditPersonalInfo(request.Name, request.Address); _studentRepository.Save(student); return(Ok()); }
public IActionResult EditPersonalInfo(long id, EditPersonalInfoRequest request) { Student student = _studentRepository.GetById(id); if (student == null) { return(Error(Errors.General.NotFound(), nameof(id))); } Address[] addresses = request.Addresses .Select(x => Address.Create(x.Street, x.City, x.State, x.ZipCode, _stateRepository.GetAll()).Value) .ToArray(); string name = request.Name.Trim(); student.EditPersonalInfo(name, addresses); _studentRepository.Save(student); return(Ok()); }