public async Task Execute(CadastraVendaModel input)
        {
            input.Validate();

            if (input.Valid)
            {
                var venda = _mapper.Map <Venda>(input);
                _repository.Create(venda);
                _outPutport.Success(new CadastraVendaOutput("Venda Cadastrada com Sucesso!"));
                return;
            }

            _outPutport.WriteError("error");
            return;
        }
示例#2
0
        public async Task Execute(CadastraVeiculoModel input)
        {
            input.Validate();

            if (input.Valid)
            {
                var veiculoInput = _mapper.Map <Veiculo>(input);
                _repository.Create(veiculoInput);
                _outPutPort.Success(new CadastraVeiculoOutput("Veiculo Cadastrado com sucesso!"));
                return;
            }

            _outPutPort.WriteError(input.Notifications);
            return;
        }
示例#3
0
        public async Task Execute(CadastraVendedorModel input)
        {
            input.Validate();

            if (input.Valid)
            {
                var vendedor = _mapper.Map <Vendedor>(input);
                _repository.Create(vendedor);

                _outputPort.Success(new CadastraVendedorOutput("Vendedor Cadastrado com Sucesso!"));
                return;
            }

            _outputPort.WriteError(input.Notifications);
            return;
        }
示例#4
0
        public Tuple <bool, string> VerifyPassword(string password)
        {
            if (password == null)
            {
                throw new ArgumentException($"{password} is null arg");
            }

            if (password == string.Empty)
            {
                return(Tuple.Create(false, $"{password} is empty "));
            }

            // check if length more than 7 chars
            if (password.Length <= 7)
            {
                return(Tuple.Create(false, $"{password} length too short"));
            }

            // check if length more than 10 chars for admins
            if (password.Length >= 15)
            {
                return(Tuple.Create(false, $"{password} length too long"));
            }

            // check if password conatins at least one alphabetical character
            if (!password.Any(char.IsLetter))
            {
                return(Tuple.Create(false, $"{password} hasn't alphanumerical chars"));
            }

            // check if password conatins at least one digit character
            if (!password.Any(char.IsNumber))
            {
                return(Tuple.Create(false, $"{password} hasn't digits"));
            }

            repository.Create(password);

            return(Tuple.Create(true, "Password is Ok. User was created"));
        }
示例#5
0
        public int?Sum(int?v1, int?v2)
        {
            if (!v1.HasValue || !v2.HasValue)
            {
                return(null);
            }

            if (v1.Value >= int.MaxValue || v2.Value >= int.MaxValue)
            {
                return(null);
            }

            var result = v1 + v2;

            var dbResult = _sqlRepository.Create();

            if (dbResult == 0)
            {
                return(null);
            }

            return(result);
        }
示例#6
0
        public void CreateVacation(VacationDto entity)
        {
            var vacation = _mapper.Map <Vacation>(entity);

            _vacationRepository.Create(vacation);
        }