Пример #1
0
        public async Task Create(UserRequestModel request)
        {
            var user = new User(request.Name, request.Login, request.Password, request.IsActive);

            if (user.Invalid)
            {
                _notificationService.AddEntityNotifications(user.ValidationResult);
                return;
            }
            await _userRepository.Create(user);
        }
Пример #2
0
        public async Task Create(SupplierRequestModel request)
        {
            var supplier = new Supplier(request.CorporateName, request.cpnj, request.TradingName,
                                        request.Email, request.Telephone, request.Address);

            if (supplier.Invalid)
            {
                _notificationService.AddEntityNotifications(supplier.ValidationResult);
                return;
            }
            await _supplierRepository.Create(supplier);
        }
        public async Task Create(ProductLineRequestModel request)
        {
            var newProductLine = new ProductLine(request.Name, request.ProductCategoryId);

            if (newProductLine.Invalid)
            {
                _notificationService.AddEntityNotifications(newProductLine.ValidationResult);
                return;
            }
            var productCategoryExists = await _productCategoryService.GetById(request.ProductCategoryId);

            if (productCategoryExists is null)
            {
                _notificationService.AddNotification("Erro ao salvar linha de produto", "Categoria de produto especificada não existe");
                return;
            }
            await _productLineRepository.Create(newProductLine);
        }
        public async Task Create(ProductCategoryRequestModel request)
        {
            await _supplierService.ValidateEntityExistence(request.SupplierId);

            if (_notificationService.HasNotifications())
            {
                return;
            }
            var productCategory = new ProductCategory(request.CategoryName, request.SupplierId);

            if (productCategory.Invalid)
            {
                _notificationService.AddEntityNotifications(productCategory.ValidationResult);
                return;
            }
            await _productCategoryRepository.Create(productCategory);
        }