parent
8d5aa412cc
commit
7dc59d2b8a
2 changed files with 38 additions and 18 deletions
|
|
@ -34,9 +34,9 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
|||
{
|
||||
model.Convocado.UsuarioModificacion = model.AtesaUser;
|
||||
model.Convocado.FechaModificacion = DateTime.Now;
|
||||
Conn.Entry(model.Convocado).State = System.Data.Entity.EntityState.Detached;
|
||||
Conn.Entry(Actual).State = System.Data.Entity.EntityState.Detached;
|
||||
Conn.Convocatoria.Attach(model.Convocado);
|
||||
Conn.Entry(model).State = System.Data.Entity.EntityState.Modified;
|
||||
Conn.Entry(model.Convocado).State = System.Data.Entity.EntityState.Modified;
|
||||
}
|
||||
Conn.SaveChanges();
|
||||
Conn.Commit();
|
||||
|
|
|
|||
|
|
@ -40,53 +40,73 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
|||
return registros;
|
||||
}
|
||||
|
||||
public BaseJson InsertarActualizarTareasPendientes(TareasPendientes model)
|
||||
public ProyectoNormativoJSON InsertarActualizarTareasPendientes(ProyectoNormativoJSON model)
|
||||
{
|
||||
TareasPendientes Actual = new TareasPendientes();
|
||||
BaseJson Respuesta = new BaseJson();
|
||||
|
||||
try
|
||||
{
|
||||
model.ClearProperties();
|
||||
|
||||
using (SinortContex Conn = new SinortContex())
|
||||
{
|
||||
Actual = Conn.TareasPendientes.Where(x => x.IdTareasPendientes == model.IdTareasPendientes).FirstOrDefault();
|
||||
Actual = Conn.TareasPendientes.Where(x => x.IdTareasPendientes == model.TareasPendientes.IdTareasPendientes).FirstOrDefault();
|
||||
if (Actual == null)
|
||||
{
|
||||
int? Next_id = Conn.Aplicacion.Max(t => (int?)t.IdAplicacion);
|
||||
model.IdTareasPendientes = (Next_id == null) ? 1 : Next_id.Value + 1;
|
||||
model.FechaCreacion = DateTime.Now;
|
||||
Conn.TareasPendientes.Add(model);
|
||||
int? Next_id = Conn.TareasPendientes.Max(t => (int?)t.IdTareasPendientes);
|
||||
model.TareasPendientes.IdTareasPendientes = (Next_id == null) ? 1 : Next_id.Value + 1;
|
||||
model.TareasPendientes.FechaCreacion = DateTime.Now;
|
||||
Conn.TareasPendientes.Add(model.TareasPendientes);
|
||||
}
|
||||
else
|
||||
{
|
||||
model.FechaModificacion = DateTime.Now;
|
||||
model.FechaCreacion = Actual.FechaCreacion;
|
||||
model.UsuarioCreacion = Actual.UsuarioCreacion;
|
||||
model.TareasPendientes.FechaModificacion = DateTime.Now;
|
||||
model.TareasPendientes.FechaCreacion = Actual.FechaCreacion;
|
||||
model.TareasPendientes.UsuarioCreacion = Actual.UsuarioCreacion;
|
||||
Conn.Entry(Actual).State = System.Data.Entity.EntityState.Detached;
|
||||
Conn.TareasPendientes.Attach(model);
|
||||
Conn.Entry(model).State = System.Data.Entity.EntityState.Modified;
|
||||
Conn.TareasPendientes.Attach(model.TareasPendientes);
|
||||
Conn.Entry(model.TareasPendientes).State = System.Data.Entity.EntityState.Modified;
|
||||
}
|
||||
Conn.SaveChanges();
|
||||
Conn.Commit();
|
||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
|
||||
model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
|
||||
}
|
||||
}
|
||||
catch (DbEntityValidationException ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Actual = null;
|
||||
}
|
||||
return Respuesta;
|
||||
return model;
|
||||
}
|
||||
public NotificacionesJSON ObtenerCantidadTareasPendientes(NotificacionesJSON model)
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
using (SinortContex db = new SinortContex())
|
||||
{
|
||||
|
||||
model.TareasPendientes = db.TareasPendientes.Where(r => r.UsuarioAsignado.ToString() == model.codigo && r.Respuesta == false).OrderBy(r => r.IdTareasPendientes).Count();
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.Error(ex);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue