Beispiel #1
0
        public async Task Guardar(ExemploViewModel obj)
        {
            var anoLectivo = _mapper.Map <Exemplo>(obj);
            await _exemploServico.Guardar(anoLectivo);

            if (!await _uow.Commit())
            {
                await _uow.Rollback();
            }
        }
Beispiel #2
0
        public async void Remover(ExemploViewModel obj)
        {
            var anoLectivo = _mapper.Map <Exemplo>(obj);

            _exemploServico.Remover(anoLectivo);

            if (!await _uow.Commit())
            {
                await _uow.Rollback();
            }
        }
Beispiel #3
0
        public ActionResult ExportarExcel2(ExemploListViewModel model)
        {
            var relatorio = _exemploRepository.ObterPorFiltro(model.Filtro);

            ExcelPackage excel     = new ExcelPackage();
            var          workSheet = excel.Workbook.Worksheets.Add("Relatório Teste");

            workSheet.TabColor         = System.Drawing.Color.Black;
            workSheet.DefaultRowHeight = 12;

            var exModel = new ExemploViewModel();

            //Header of table
            workSheet.Row(1).Height = 20;
            workSheet.Row(1).Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
            workSheet.Row(1).Style.Font.Bold           = true;

            workSheet.Cells[1, 1].Value = exModel.DisplayNameFor(x => x.EXEMPLO_ID);
            workSheet.Cells[1, 2].Value = exModel.DisplayNameFor(x => x.NOME);
            workSheet.Cells[1, 3].Value = exModel.DisplayNameFor(x => x.DESCRICAO);
            workSheet.Cells[1, 4].Value = exModel.DisplayNameFor(x => x.ATIVO);

            //Size columns
            workSheet.Column(1).Width = 10;
            workSheet.Column(2).Width = 30;
            workSheet.Column(3).Width = 50;
            workSheet.Column(4).Width = 10;

            //Body of table
            int recordIndex = 2;

            foreach (var item in relatorio)
            {
                workSheet.Cells[recordIndex, 1].Value = item.EXEMPLO_ID;
                workSheet.Cells[recordIndex, 2].Value = item.NOME;
                workSheet.Cells[recordIndex, 3].Value = item.DESCRICAO;
                workSheet.Cells[recordIndex, 4].Value = (item.ATIVO) ? "Ativo" : "Inativo";
                recordIndex++;
            }

            string excelName = string.Format("Relatório Teste {0}.xlsx", DateTime.Now.ToString("dd-MM-yyyy-HH-mm"));

            byte[] filecontent = excel.GetAsByteArray();

            return(File(filecontent, MediaTypeNames.Application.Octet, excelName));
        }
Beispiel #4
0
        public ActionResult Create()
        {
            var model = new ExemploViewModel();

            return(PartialView("_Create", model));
        }