コード例 #1
0
        private async Task ClienteValidation(Cliente cliente)
        {
            var currentClientes = await _unitOfWork.ClienteRepository.GetAll();

            _phoneNumberValidation.ValidatePhoneNumber(cliente.Telefono);
            _validateEmail.ValidateEmailProveedor(cliente.Email);
            _validateDni.ValidateDNI(cliente.Dni);
            _fechaValidation.ValidateFecha(cliente.Nacimiento);
            await _sangreValidation.ValidateSangre(cliente.IdSangre);

            if (currentClientes.Where(x => x.Dni == cliente.Dni).Any())
            {
                throw new BussinessException("El DNI Ya existe", 400);
            }

            if (currentClientes.Where(x => x.Email.ToLower() == cliente.Email.ToLower()).Any())
            {
                throw new BussinessException("El Email Ya existe", 400);
            }

            if (currentClientes.Where(x => x.Telefono == cliente.Telefono).Any())
            {
                throw new BussinessException("Ya existe el telefono", 400);
            }

            if (DateTime.Parse(cliente.Nacimiento).Year > (DateTime.Now.Year - 18))
            {
                throw new BussinessException("Usted no tiene la edad requerida", 400);
            }
        }
コード例 #2
0
        public async Task UsuarioValidation(Usuario usuario)
        {
            _emailValidation.ValidateEmailProveedor(usuario.Email);
            await _rolValidation.ValidateRol((int)usuario.IdRol);

            await _sangreValidation.ValidateSangre(usuario.IdSangre);

            var usuarios = await _unitOfWork.UsuarioRepository.GetAll();

            if (usuarios.Where(x => x.Email.ToLower() == usuario.Email.ToLower()).Any())
            {
                throw new BussinessException("El usuario ya existe", 400);
            }
        }