Exemple #1
0
        public List <SelectListItem> GetAllTecnicos(int id_empresa)
        {
            try
            {
                var tecnicos = _tecnicoService.Get(s => s.Id_Empresa == id_empresa).Select(s => new SelectListItem()
                {
                    Text = s.Nome.ToString(), Value = s.Id_Tecnico.ToString()
                }).ToList();

                return(tecnicos);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
        public IActionResult Index()
        {
            try
            {
                var empresa_Global = Convert.ToInt32(Request.Cookies["empresa_global"]);
                //var cliente = _clienteService.Get(c => c.)
                var perfil = User.Claims.FirstOrDefault(c => c.Type == "Perfil");

                IEnumerable <Chamado> chamadosEntidade = null;

                if (perfil != null && (perfil.Value == EnumPerfil.Administrador.ToString() || perfil.Value == EnumPerfil.Distribuidora.ToString()))
                {
                    chamadosEntidade = _chamadoService.GetAll().Where(c => c.Id_Empresa == empresa_Global);
                }
                else if (perfil != null && perfil.Value == EnumPerfil.Cliente.ToString())
                {
                    var id_usuario = User.Claims.FirstOrDefault(cl => cl.Type == EnumTypeClaims.Id_Usuario.ToString());
                    var cliente    = _clienteService.Get(c => c.Id_Usuario == Convert.ToInt32(id_usuario.Value)).FirstOrDefault();
                    if (cliente != null)
                    {
                        chamadosEntidade = _chamadoService.GetAll().Where(c => c.Id_Empresa == empresa_Global && c.Id_Cliente == cliente.Id_Cliente);
                    }
                }
                else if (perfil != null && perfil.Value == EnumPerfil.Tecnico.ToString())
                {
                    var id_usuario = User.Claims.FirstOrDefault(cl => cl.Type == EnumTypeClaims.Id_Usuario.ToString());
                    var tecnico    = _tecnicoService.Get(c => c.Id_Usuario == Convert.ToInt32(id_usuario.Value)).FirstOrDefault();
                    if (tecnico != null)
                    {
                        chamadosEntidade = _chamadoService.GetAll().Where(c => c.Id_Empresa == empresa_Global && c.Id_Tecnico == tecnico.Id_Tecnico);
                    }
                }

                List <ChamadoVM> chamados = new List <ChamadoVM>();
                if (chamadosEntidade != null)
                {
                    chamados = _mapper.Map <IEnumerable <ChamadoVM> >(chamadosEntidade).ToList();
                }

                return(View(chamados));
            }
            catch (Exception e)
            {
                return(View(e));

                throw;
            }
        }