예제 #1
0
        private OperationResult ValidarModelo(TicketVm obj)
        {
            var resultado = new OperationResult();

            if (String.IsNullOrWhiteSpace(obj.Tema))
            {
                resultado.Agregar("You must specify the ticket's subject");
            }

            if (String.IsNullOrWhiteSpace(obj.Descripcion))
            {
                resultado.Agregar("You must specify the ticket's Description");
            }

            if (obj.ListaEmpleado == null || obj.ListaEmpleado.Count() <= 0)
            {
                resultado.Agregar("You must specify at least one employee for the ticket");
            }

            foreach (var item in obj.ListaEntrada)
            {
                if (item.Nota == "")
                {
                    resultado.Agregar("You must specify the nota for the entry ");
                }

                if (item.EmpleadoId <= 0)
                {
                    resultado.Agregar("You must specify the employee for the entry " + item.Nota);
                }
            }

            return(resultado);
        }
예제 #2
0
        private OperationResult ValidarModelo(EmpleadoVm obj)
        {
            var resultado = new OperationResult();

            if (String.IsNullOrWhiteSpace(obj.Nombre))
            {
                resultado.Agregar("You must specify the employee's name");
            }

            if (String.IsNullOrWhiteSpace(obj.Apellido))
            {
                resultado.Agregar("You must specify the employee's Last Name");
            }

            if (String.IsNullOrWhiteSpace(obj.Cedula))
            {
                resultado.Agregar("You must specify the employee's Id");
            }

            if (String.IsNullOrWhiteSpace(obj.Email))
            {
                resultado.Agregar("You must specify the employee's email");
            }

            if (String.IsNullOrWhiteSpace(obj.Sexo))
            {
                resultado.Agregar("You must specify the employee's gender");
            }

            return(resultado);
        }
예제 #3
0
        private OperationResult ValidarModelo(UsuarioVm obj)
        {
            var resultado = new OperationResult();

            if (String.IsNullOrWhiteSpace(obj.UserName))
            {
                resultado.Agregar("You must specify the user's name");
            }

            if (String.IsNullOrWhiteSpace(obj.UserPassword))
            {
                resultado.Agregar("You must specify the user's Password");
            }

            return(resultado);
        }
예제 #4
0
        public OperationResult Eliminar(int id)
        {
            var resultado = new OperationResult();

            var obj = _repository.Obtener(id);

            if (obj == null)
            {
                throw new InvalidOperationException("The registry doesn't exist.");
            }

            var entrada = _ticketEntradaRepository.ObtenerPorTicket(id);

            if (entrada != null)
            {
                resultado.Agregar("This ticket can't be eliminated because it has entry references");
            }

            if (resultado.EsValido)
            {
                _repository.Eliminar(obj);
            }

            return(resultado);
        }
예제 #5
0
        public OperationResult InActivar(int usuarioId)
        {
            var obj = _repository.Obtener(usuarioId);

            if (obj == null)
            {
                throw new InvalidOperationException("The registry doesn't exist.");
            }

            var resultado = new OperationResult();

            if (obj.Estado == false)
            {
                resultado.Agregar("This registry is alredy inactive.");
                return(resultado);
            }

            obj.Estado = false;
            _repository.Actualizar(obj);

            return(resultado);
        }