public static int ObtenerSecuencia(int area) { var tareas1 = new TareasIng(); DateTime hoy = DateTime.Now; int correlativo = 0; try { using (var ctx = new inventarioContext()) { tareas1 = ctx.TareasIng .Where(x => x.IdArea == area) .Where(x => x.FechaEjecucion.Value.Year == hoy.Year) .Where(x => x.secuencia != null) .OrderByDescending(x => x.secuencia) .FirstOrDefault(); correlativo = 0; } } catch (Exception e) { throw; } if (tareas1 != null) { if (tareas1.secuencia == null) { correlativo = 0; } else { correlativo = (int)tareas1.secuencia; } } else { correlativo = 0; } return(correlativo + 1); }
public ResponseModel Finalizar(int idTareaing, string resultado) { DateTime hoy = DateTime.Now; var rm = new ResponseModel(); string sql; int area = responsable.ObtenerArea(SessionHelper.GetIdUser()); int secuencia = TareasIng.ObtenerSecuencia(area); try { using (var ctx = new inventarioContext()) { sql = "UPDATE dbo.TareasIng SET IdEstadoTareaIng=4, secuencia=" + secuencia + ", Resultado='" + resultado + "', FechaFin='" + hoy.ToString("s") + "' WHERE IdTareaIng=" + idTareaing; ctx.Database.ExecuteSqlCommand(sql); rm.SetResponse(true); } } catch (Exception) { throw; } return(rm); }
public TareasIng Obtener(int id) { var tareaing = new TareasIng(); try { using (var ctx = new inventarioContext()) { ctx.Configuration.LazyLoadingEnabled = true; ctx.Configuration.ProxyCreationEnabled = false; tareaing = ctx.TareasIng.Where(x => x.IdTareaIng == id) .Include(x => x.responsable.areas) .Include(x => x.responsable.usuariosSistema) .Include(x => x.AutorizadorTarea.responsable.usuariosSistema) .SingleOrDefault(); } } catch (Exception) { throw; } return(tareaing); }