예제 #1
0
        // GET: Linha
        public ViewResult Index(int?pagina, string numero)
        {
            int itensPorPagina = 12;
            int paginat        = pagina ?? 1;

            List <LinhaModel> lista = new List <LinhaModel>();

            lista = new LinhaDao().Listar(new LinhaModel {
                Numero = numero
            });

            return(View(lista.ToPagedList(paginat, itensPorPagina)));
        }
예제 #2
0
        public static Linha ToBd(this LinhaDao linhaDao)
        {
            Linha linha = new Linha();

            linha.LinhaID = linhaDao.LinhaID;
            if (!string.IsNullOrEmpty(linhaDao.Descricao))
            {
                linha.Descricao = linhaDao.Descricao.Trim();
            }
            linha.Ativo = linhaDao.Ativo;

            return(linha);
        }
예제 #3
0
        private void ValidarIncluir(LinhaDao linhaDao)
        {
            if (linhaDao == null)
            {
                throw new BusinessException("Linha é obrigatório");
            }

            if (string.IsNullOrEmpty(linhaDao.Descricao))
            {
                throw new BusinessException("Descrição é obrigatório");
            }

            if (linhaRepository.Listar(new Linha()
            {
                Descricao = linhaDao.Descricao
            }).FirstOrDefault() != null)
            {
                throw new BusinessException("Linha (Descrição) já cadastrada");
            }
        }
예제 #4
0
        public List <LinhaDao> Listar(LinhaDao linhaDao)
        {
            try
            {
                return(linhaRepository.Listar(linhaDao.ToBd()).Select(x => x.ToApp()).ToList());
            }
            catch (BusinessException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                // inclui o log do erro
                logRepository.Incluir(new Log()
                {
                    Descricao = ex.ToString(), DataHora = DateTime.Now
                });

                throw ex;
            }
        }
예제 #5
0
        public int Incluir(LinhaDao linhaDao)
        {
            try
            {
                ValidarIncluir(linhaDao);

                return(linhaRepository.Incluir(linhaDao.ToBd()));
            }
            catch (BusinessException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                // inclui o log do erro
                logRepository.Incluir(new Log()
                {
                    Descricao = ex.ToString(), DataHora = DateTime.Now
                });

                throw ex;
            }
        }
예제 #6
0
        // GET: Linha/Delete/
        public ActionResult Delete(int id)
        {
            var model = new LinhaDao().Obter(id);

            return(View(model));
        }