예제 #1
0
        public async Task<Phone> Insert(Phone phone) {
            //Phone phone = new Phone(obj.Ddd, obj.PhoneNumber, await _typeGenericRepository.GetById(obj.TypeGenericId));

            phone.Validate(phone, new PhoneValidator());
            _notifications.AddNotifications(phone.ValidationResult);

            if (phone.GraduateId != null) {
                phone.Graduate = await _graduateRepository.GetById(phone.GraduateId);
            }

            if (phone.Invalid) {
                _notifications.AddNotifications(phone.ValidationResult);
            }

            if (!_notifications.HasNotifications) {
                await Post(phone);
            }

            return phone;
        }
        public async Task <Address> Insert(Address address)
        {
            address.Validate(address, new AddressValidator());
            _notifications.AddNotifications(address.ValidationResult);
            //Address address = new Address(obj.Cep, obj.Street, obj.Number, obj.Complement, obj.Neighborhood, obj.City, obj.Uf, await _typeGenericRepository.GetById(obj.TypeGenericId));

            if (address.GraduateId != null)
            {
                address.Graduate = await _graduateRepository.GetById(address.GraduateId);
            }

            if (address.Invalid)
            {
                _notifications.AddNotifications(address.ValidationResult);
            }

            if (!_notifications.HasNotifications)
            {
                await Post(address);
            }

            return(address);
        }