コード例 #1
0
        public async Task <College> Update(CollegeDto CollegeDto)
        {
            College College = await _CollegeRepository.GetAllById(CollegeDto.CollegeId);

            _mapper.Map(CollegeDto, College);

            College.Validate(College, new CollegeValidator());
            _notifications.AddNotifications(College.ValidationResult);

            foreach (var item in College.Address)
            {
                item.Validate(item, new AddressValidator());
                _notifications.AddNotifications(item.ValidationResult);
            }

            foreach (var item in College.Phone)
            {
                item.Validate(item, new PhoneValidator());
                _notifications.AddNotifications(item.ValidationResult);
            }

            if (!_notifications.HasNotifications)
            {
                await Put(College);
            }

            return(College);
        }