public DetalleSolicitudes Get(int id) { var result = new DetalleSolicitudes(); /*Usando Entity Framework*/ using (var db = new ApplicationDbContext()) { result = db.DetalleSolicitudes.Where(i => i.DetalleSolicitudID == id) .FirstOrDefault(); } return(result); }
//[Authorize(Policy = "AllowEditDetalleSolicitud")] public IActionResult Solicitar(DetalleSolicitudes model) { //var da = new ProductDA(); model.estado = 1; var result = DetalleSolicitudesDA.Insert(model); if (result > 0) { return(RedirectToAction("IndexSolicitante")); //Redireccionamos al listado } else { return(View(model)); } }
public int Insert(DetalleSolicitudes entity) { var result = 1; using (var db = new ApplicationDbContext()) { if (entity.SolicitudID == 1) { entity.MotivoViaje = "CapacitaciĆ³n del personal y nuevos proyectos"; } else if (entity.SolicitudID == 2) { entity.MotivoViaje = "otros"; } db.Add(entity); result = db.SaveChanges(); } return(result); }
public bool Update(DetalleSolicitudes entity) { var result = false; using (var db = new ApplicationDbContext()) { if (entity.SolicitudID == 1) { entity.MotivoViaje = "CapacitaciĆ³n del personal y nuevos proyectos"; } else if (entity.SolicitudID == 2) { entity.MotivoViaje = "otros"; } db.DetalleSolicitudes.Attach(entity); db.Entry(entity).State = EntityState.Modified; result = db.SaveChanges() != 0; } return(result); }
public IActionResult Aprobacion(DetalleSolicitudes model, String flagaprobacion) { //var da = new ProductDA(); if (flagaprobacion == "Rechazar") { model.estado = 0; } else { model.estado = 2; } var result = DetalleSolicitudesDA.Update(model); if (result) //Si es verdadero { return(RedirectToAction("Index")); //Redireccionamos al listado } else { return(View(model)); } }