// GET: Optimizar public async Task <IActionResult> Index() { try { if (!(await trabajadorRepository.EsJefe()).Item2) { return(Unauthorized("No tiene permisos para ver este contenido.")); } ViewBag.CantidadAlarmas = (await producto.GetCantidadAlarmas()).Cantidad; return(View()); } catch (Exception e) { return(StatusCode((int)System.Net.HttpStatusCode.Unauthorized, e.Message)); //return Unauthorized(e.Message); } }
// GET: Producto/Create public async Task <IActionResult> Create() { try { if (!(await trabajadorRepository.EsJefe()).Item2) { return(Unauthorized("No tiene permisos para ver este contenido.")); } ViewBag.CantidadAlarmas = (await productoRepository.GetCantidadAlarmas()).Cantidad; ViewData["IdCategoria"] = new SelectList(await categoriaRepository.GetAll(), "IdCategoria", "Nombre"); return(View()); } catch (Exception e) { return(StatusCode((int)System.Net.HttpStatusCode.Unauthorized, e.Message)); //return Unauthorized(e.Message); } }