예제 #1
0
        public IActionResult EditPersonalInfo(long id, [FromBody] EditPersonalInfoRequest request)
        {
            Student student = _studentRepository.GetById(id);

            student.EditPersonalInfo(request.Name, request.Address);
            _studentRepository.Save(student);

            return(Ok());
        }
예제 #2
0
        public IActionResult EditPersonalInfo(long id, StudentDto request)
        {
            Student student = _studentRepository.GetById(id);

            var validator = new StudentValidator();

            validator.Validate(request);

            var addresses = request.Addresses.Select(a => new Address(a.Street, a.City, a.State, a.ZipCode)).ToList();

            //student.EditPersonalInfo(new StudentName(request.Name), addresses);
            _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());
        }