public async Task <ActionResult> Deletepop(int id) { IndicadorsController controlIndicador = new IndicadorsController(db, userManager); ConfiguracionsController controlConfiguracion = new ConfiguracionsController(db, userManager); NotaIndicador nota = await db.NotaIndicador.FindAsync(id); Indicador indicador = await controlIndicador.getFromId(nota.Indicador.id); var userFull = await userManager.FindByEmailAsync(User.Identity.Name); var notasE = User.HasClaim(c => (c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/Nota.Editar" && c.Value == "1")); var super = User.HasClaim(c => (c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/Super" && c.Value == "1")); ViewBag.editar = controlConfiguracion.Editable(userFull.IDDependencia, indicador.Categoria, notasE, super); ViewBag.visible = true; ViewBag.configuracion = await controlConfiguracion.Get(); ViewBag.indicador = indicador; ViewBag.userFull = userFull; return(View(nota)); }
public async Task <bool> CreatepopAsync(NotaIndicador nota) { try { db.NotaIndicador.Add(nota); await db.SaveChangesAsync(); return(true); } catch (Exception e) { Indicador indicador = await db.Indicador.FindAsync(nota.IdIndicador); List <SelectListItem> IndicadorLista = new List <SelectListItem>(); IndicadorLista.Add(new SelectListItem() { Text = indicador.codigo + " " + indicador.nombre, Value = indicador.id.ToString() }); ViewBag.IdIndicador = new SelectList(IndicadorLista, "Value", "Text", "Vale"); var userFull = await userManager.FindByEmailAsync(User.Identity.Name); List <SelectListItem> usuarioLista = new List <SelectListItem>(); usuarioLista.Add(new SelectListItem() { Text = userFull.Nombre + " " + userFull.Apellido, Value = userFull.Id }); ViewBag.UserId = new SelectList(usuarioLista, "Value", "Text", "Value"); return(false); } }
public async Task <ActionResult> Editpop(int id, int idindicador) { NotaIndicador nota = await db.NotaIndicador.FindAsync(id); var userFull = await userManager.FindByEmailAsync(User.Identity.Name); //ViewBag.IdCategoria = new SelectList(db.Categorias, "id", "numero"); //ViewBag.UserId = new SelectList(db.Users, "Id", "Nombre"); Indicador indicador = await db.Indicador.FindAsync(idindicador); List <SelectListItem> usuarioLista = new List <SelectListItem>(); usuarioLista.Add(new SelectListItem() { Text = userFull.Nombre + " " + userFull.Apellido, Value = userFull.Id }); List <SelectListItem> IndicadorLista = new List <SelectListItem>(); IndicadorLista.Add(new SelectListItem() { Text = indicador.codigo + " " + indicador.nombre, Value = indicador.id.ToString() }); List <SelectListItem> EstadoLista = new List <SelectListItem>(); EstadoLista.Add(new SelectListItem() { Text = "Abierta", Value = "Abierta" }); EstadoLista.Add(new SelectListItem() { Text = "Cerrada", Value = "Cerrada" }); ViewBag.IdIndicador = new SelectList(IndicadorLista, "Value", "Text", nota.IdIndicador); ViewBag.UserId = new SelectList(usuarioLista, "Value", "Text", nota.UserId); ViewBag.Estado = new SelectList(EstadoLista, "Value", "Text", nota.Estado); return(View(nota)); }
public async Task <bool> Editpop(NotaIndicador nota) { //----------------INICIO EVITA QUE UN USUARIO PUEDA MODIFICAR UNA NOTA CAMBIANDO EL DATA-ID string notaoldUserId = await db.NotaIndicador.Where(n => n.Id == nota.Id).Select(n => n.UserId).FirstOrDefaultAsync(); var userFull = await userManager.FindByEmailAsync(User.Identity.Name); if (User.Identity.Name != null) { if (userFull.Id == notaoldUserId) { //----------------INICIO EVITA QUE UN USUARIO PUEDA MODIFICAR UNA NOTA CAMBIANDO EL DATA-ID if (ModelState.IsValid) { db.Entry(nota).State = EntityState.Modified; await db.SaveChangesAsync(); return(true); } } } Indicador indicador = await db.Indicador.FindAsync(nota.IdIndicador); List <SelectListItem> IndicadorLista = new List <SelectListItem>(); IndicadorLista.Add(new SelectListItem() { Text = indicador.codigo + " " + indicador.nombre, Value = indicador.id.ToString() }); ViewBag.IdIndicador = new SelectList(IndicadorLista, "Value", "Text", "Vale"); List <SelectListItem> usuarioLista = new List <SelectListItem>(); usuarioLista.Add(new SelectListItem() { Text = userFull.Nombre + " " + userFull.Apellido, Value = userFull.Id }); ViewBag.UserId = new SelectList(usuarioLista, "Value", "Text", "Value"); return(false); }
public async Task <bool> DeleteConfirmedpop(int id) { NotaIndicador nota = await db.NotaIndicador.FindAsync(id); var userFull = await userManager.FindByEmailAsync(User.Identity.Name); if (userFull.Id != nota.UserId) { return(false); } //----------------INICIO EVITA QUE UN USUARIO PUEDA MODIFICAR UNA NOTA CAMBIANDO EL DATA-ID db.NotaIndicador.Remove(nota); await db.SaveChangesAsync(); return(true); }