예제 #1
0
        public async Task <IActionResult> Edit(UsuarioDto usuarioDto)
        {
            ViewBag.Perfil = Combos.retornarOpcoesPerfil();
            ViewBag.Status = Combos.retornarOpcoesStatus();
            if (usuarioDto.Id == null)
            {
                return(NotFound());
            }

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

            await _usuarioService.Editar(usuarioDto);

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

            TempData["Notificacao"] = new BadRequestDto(new List <Notification>()
            {
                new Notification("EditarUsuario", "Usuário editado com sucesso.")
            }, TipoNotificacao.Success);
            ViewBag.Controller = "Usuarios";
            return(View("_Confirmacao"));
        }
예제 #2
0
        public async Task <IActionResult> Create(UsuarioDto usuarioDto)
        {
            ViewBag.Perfil = Combos.retornarOpcoesPerfil();

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

            await _usuarioService.Criar(usuarioDto);

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

            TempData["Notificacao"] = new BadRequestDto(new List <Notification>()
            {
                new Notification("CadastrarUsuario", "Usuário cadastrado com sucesso.")
            }, TipoNotificacao.Success);
            ViewBag.Controller = "Usuarios";
            return(View("_Confirmacao"));
        }
예제 #3
0
        // GET: Usuarios/Edit/5
        public async Task <IActionResult> Edit(Guid id)
        {
            var usuario = await _usuarioService.Obter(id);

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

            ViewBag.Perfil = Combos.retornarOpcoesPerfil();
            ViewBag.Status = Combos.retornarOpcoesStatus();

            return(View(new UsuarioDto(usuario)));
        }
        public IActionResult GerarRelatorio(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.Perfil     = new SelectList(Combos.retornarOpcoesPerfil(), "Value", "Text", (int)filtro.PerfilUsuario);
            ViewBag.TipoLocal  = new SelectList(Combos.retornarOpcoesSala(), "Value", "Text", (int)filtro.TipoLocal);

            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 (filtro.PerfilUsuario != EnumTipoPerfil.Nenhum)
            {
                agendamentos = agendamentos.Where(a => a.Usuario.Perfil == filtro.PerfilUsuario);
            }

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

            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("Relatorio", retorno));
        }
예제 #5
0
 // GET: Usuarios/Create
 public IActionResult Create()
 {
     ViewBag.Perfil = Combos.retornarOpcoesPerfil();
     return(View());
 }