public async Task <TypeGeneric> Insert(TypeGeneric obj)
        {
            obj.Validate(obj, new TypeGenericValidator());
            _notifications.AddNotifications(obj.ValidationResult);

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

            return(obj);
        }
        public async Task <Course> Insert(Course course)
        {
            course.Validate(course, new CourseValidator());
            _notifications.AddNotifications(course.ValidationResult);

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

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

            return(course);
        }
Пример #3
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;
        }
Пример #4
0
        public async Task <Seller> Insert(Seller obj)
        {
            obj.Validate(obj, new SellerValidator());
            _notifications.AddNotifications(obj.ValidationResult);

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

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

            if (!_notifications.HasNotifications)
            {
                obj.AddUser(await CreateUser(obj.Cpf, obj.Email));
            }


            //NOTA# adicionar uma condição para se caso der errado para adiconar um novo usuario apagar o usuario criado
            if (!_notifications.HasNotifications)
            {
                await Post(obj);
            }

            return(obj);
        }
        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);
        }
Пример #6
0
        public async Task <ShippingCompany> Insert(ShippingCompany obj)
        {
            obj.Validate(obj, new ShippingCompanyValidator());
            _notifications.AddNotifications(obj.ValidationResult);

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

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

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

            return(obj);
        }
        public async Task <College> Insert(College obj)
        {
            obj.Validate(obj, new CollegeValidator());
            _notifications.AddNotifications(obj.ValidationResult);

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

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

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

            return(obj);
        }