コード例 #1
0
        public async Task <IActionResult> Create(AgendamentoDto dto)
        {
            ViewBag.Periodo  = Combos.retornarOpcoesPeriodo();
            ViewBag.TipoSala = Combos.retornarOpcoesSala();

            dto.Validate();
            if (dto.Invalid)
            {
                TempData["Notificacao"] = new BadRequestDto(dto.Notifications, TipoNotificacao.Warning);
                return(View(dto));
            }

            await _agendamentoService.CriarAsync(dto);

            if (_agendamentoService.Invalid)
            {
                TempData["Notificacao"] = new BadRequestDto(_agendamentoService.Notifications, TipoNotificacao.Warning);
                return(View(dto));
            }

            TempData["Notificacao"] = new BadRequestDto(new List <Notification>()
            {
                new Notification("CadastrarAgendamento", "Agendamento cadastrado com sucesso.")
            }, TipoNotificacao.Success);
            ViewBag.Controller = "Agendamentos";
            return(View("_Confirmacao"));
        }
コード例 #2
0
        public async Task <IActionResult> Create(SalaDto salaDto)
        {
            ViewBag.TipoSala     = Combos.retornarOpcoesSala();
            ViewBag.Equipamentos = new SelectList(_equipamentoService.ObterSemSala(), "Id", "NomeModelo");

            salaDto.Validate();
            if (salaDto.Invalid)
            {
                TempData["Notificacao"] = new BadRequestDto(salaDto.Notifications, TipoNotificacao.Warning);
                return(View(salaDto));
            }

            await _salaService.CriarAsync(salaDto);

            if (_salaService.Invalid)
            {
                TempData["Notificacao"] = new BadRequestDto(_salaService.Notifications, TipoNotificacao.Warning);
                return(View(salaDto));
            }

            TempData["Notificacao"] = new BadRequestDto(new List <Notification>()
            {
                new Notification("CadastrarSala", "Sala cadastrada com sucesso.")
            }, TipoNotificacao.Success);
            ViewBag.Controller = "Salas";
            return(View("_Confirmacao"));
        }
コード例 #3
0
        // GET: Agendamentos/Create
        public IActionResult Create()
        {
            ViewBag.Periodo  = Combos.retornarOpcoesPeriodo();
            ViewBag.TipoSala = Combos.retornarOpcoesSala();

            return(View());
        }
コード例 #4
0
        //GET: Salas/Create
        public IActionResult Create()
        {
            ViewBag.TipoSala     = Combos.retornarOpcoesSala();
            ViewBag.Equipamentos = new SelectList(_equipamentoService.ObterSemSala(), "Id", "NomeModelo");

            return(View());
        }
コード例 #5
0
        public async Task <IActionResult> Edit(SalaDto salaDto)
        {
            ViewBag.TipoSala     = new SelectList(Combos.retornarOpcoesSala(), "Value", "Text", salaDto.Tipo);
            ViewBag.Equipamentos = _equipamentoService.ObterPorSalaEdicao(salaDto.Id.Value);
            ViewBag.Status       = Combos.retornarOpcoesStatus();

            salaDto.Validate();
            if (salaDto.Invalid)
            {
                TempData["Notificacao"] = new BadRequestDto(salaDto.Notifications, TipoNotificacao.Warning);
                return(View(salaDto));
            }

            await _salaService.EditarAsync(salaDto);

            if (_salaService.Invalid)
            {
                TempData["Notificacao"] = new BadRequestDto(_salaService.Notifications, TipoNotificacao.Warning);
                return(View(salaDto));
            }

            TempData["Notificacao"] = new BadRequestDto(new List <Notification>()
            {
                new Notification("EditarSala", "Sala editada com sucesso.")
            }, TipoNotificacao.Success);
            ViewBag.Controller = "Salas";
            return(View("_Confirmacao"));
        }
コード例 #6
0
        public IActionResult RelatorioAprovados(AgendamentoRelatorioFiltroDto filtro)
        {
            filtro.DataInicio ??= DateTime.Now.Date;
            filtro.DataFim ??= DateTime.Now.Date.AddDays(10);

            ViewBag.DataInicio = filtro.DataInicio.Value.Date.ToString("yyyy-MM-dd");
            ViewBag.DataFim    = filtro.DataFim.Value.Date.ToString("yyyy-MM-dd");
            ViewBag.Sala       = filtro.Sala ?? string.Empty;
            ViewBag.Usuario    = filtro.Usuario ?? string.Empty;
            ViewBag.TipoLocal  = new SelectList(Combos.retornarOpcoesSala(), "Value", "Text", (int)filtro.TipoLocal);
            ViewBag.Status     = new SelectList(Combos.retornarOpcoesStatusAgendamento(), "Value", "Text");

            var agendamentos = _agendamentoService.GerarRelatorio(filtro.DataInicio.Value, filtro.DataFim.Value);

            if (filtro.TipoLocal != EnumTipoSala.Nenhum)
            {
                agendamentos = agendamentos.Where(a => a.Sala.Tipo == filtro.TipoLocal);
            }

            if (!string.IsNullOrEmpty(filtro.Sala))
            {
                agendamentos = agendamentos.Where(a => a.Sala.IdentificadorSala.ToLower().Contains(filtro.Sala.ToLower()));
            }

            if (!string.IsNullOrEmpty(filtro.Usuario))
            {
                agendamentos = agendamentos.Where(a => a.Usuario.Nome.ToLower().Contains(filtro.Usuario.ToLower()));
            }

            if (filtro.StatusAgendamento != null)
            {
                ViewBag.Status = new SelectList(Combos.retornarOpcoesStatusAgendamento(), "Value", "Text", (int)filtro.StatusAgendamento);

                agendamentos = agendamentos.Where(a => a.Status == filtro.StatusAgendamento);
            }

            var usuariosAprovadores = _usuarioService.ObterPorPerfil(EnumTipoPerfil.Administrador);

            var retorno = new List <AgendamentoRelatorioDto>();

            foreach (var agendamento in agendamentos)
            {
                var aprovador = usuariosAprovadores.Where(u => u.Id == agendamento.AprovadorId).FirstOrDefault();

                retorno.Add(new AgendamentoRelatorioDto(agendamento, aprovador));
            }

            return(View("RelatorioAprovacao", retorno));
        }
コード例 #7
0
        // GET: Salas/Edit/5
        public async Task <IActionResult> Edit(Guid id)
        {
            var sala = await _salaService.ObterAsync(id);

            if (_salaService.Invalid)
            {
                TempData["Notificacao"] = new BadRequestDto(_salaService.Notifications, TipoNotificacao.Warning);
                ViewBag.Controller      = "Salas";
                return(View("_Confirmacao"));
            }

            ViewBag.TipoSala     = new SelectList(Combos.retornarOpcoesSala(), "Value", "Text", sala.Tipo);
            ViewBag.Equipamentos = _equipamentoService.ObterPorSalaEdicao(sala.Id);
            ViewBag.Status       = Combos.retornarOpcoesStatus();

            return(View(new SalaDto(sala)));
        }
コード例 #8
0
        //GET: Agendamentos/Edit/5
        public async Task <IActionResult> Edit(Guid id)
        {
            var agendamento = await _agendamentoService.ObterAsync(id);

            if (_agendamentoService.Invalid)
            {
                TempData["Notificacao"] = new BadRequestDto(_agendamentoService.Notifications, TipoNotificacao.Warning);
                ViewBag.Controller      = "Agendamentos";
                return(View("_Confirmacao"));
            }

            ViewBag.Tipo = (int)agendamento.Sala.Tipo;
            ViewBag.Sala = agendamento.SalaId;

            ViewBag.Periodo  = Combos.retornarOpcoesPeriodo();
            ViewBag.TipoSala = Combos.retornarOpcoesSala();

            return(View(new AgendamentoDto(agendamento)));
        }