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.UsuarioModificacion = model.AtesaUser;
|
||||||
model.Convocado.FechaModificacion = DateTime.Now;
|
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.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.SaveChanges();
|
||||||
Conn.Commit();
|
Conn.Commit();
|
||||||
|
|
|
||||||
|
|
@ -40,53 +40,73 @@ namespace AYA.SlnSinortModel.DAL.Sinort
|
||||||
return registros;
|
return registros;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseJson InsertarActualizarTareasPendientes(TareasPendientes model)
|
public ProyectoNormativoJSON InsertarActualizarTareasPendientes(ProyectoNormativoJSON model)
|
||||||
{
|
{
|
||||||
TareasPendientes Actual = new TareasPendientes();
|
TareasPendientes Actual = new TareasPendientes();
|
||||||
BaseJson Respuesta = new BaseJson();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
model.ClearProperties();
|
model.ClearProperties();
|
||||||
|
|
||||||
using (SinortContex Conn = new SinortContex())
|
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)
|
if (Actual == null)
|
||||||
{
|
{
|
||||||
int? Next_id = Conn.Aplicacion.Max(t => (int?)t.IdAplicacion);
|
int? Next_id = Conn.TareasPendientes.Max(t => (int?)t.IdTareasPendientes);
|
||||||
model.IdTareasPendientes = (Next_id == null) ? 1 : Next_id.Value + 1;
|
model.TareasPendientes.IdTareasPendientes = (Next_id == null) ? 1 : Next_id.Value + 1;
|
||||||
model.FechaCreacion = DateTime.Now;
|
model.TareasPendientes.FechaCreacion = DateTime.Now;
|
||||||
Conn.TareasPendientes.Add(model);
|
Conn.TareasPendientes.Add(model.TareasPendientes);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model.FechaModificacion = DateTime.Now;
|
model.TareasPendientes.FechaModificacion = DateTime.Now;
|
||||||
model.FechaCreacion = Actual.FechaCreacion;
|
model.TareasPendientes.FechaCreacion = Actual.FechaCreacion;
|
||||||
model.UsuarioCreacion = Actual.UsuarioCreacion;
|
model.TareasPendientes.UsuarioCreacion = Actual.UsuarioCreacion;
|
||||||
Conn.Entry(Actual).State = System.Data.Entity.EntityState.Detached;
|
Conn.Entry(Actual).State = System.Data.Entity.EntityState.Detached;
|
||||||
Conn.TareasPendientes.Attach(model);
|
Conn.TareasPendientes.Attach(model.TareasPendientes);
|
||||||
Conn.Entry(model).State = System.Data.Entity.EntityState.Modified;
|
Conn.Entry(model.TareasPendientes).State = System.Data.Entity.EntityState.Modified;
|
||||||
}
|
}
|
||||||
Conn.SaveChanges();
|
Conn.SaveChanges();
|
||||||
Conn.Commit();
|
Conn.Commit();
|
||||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.EXITOSO.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (DbEntityValidationException ex)
|
catch (DbEntityValidationException ex)
|
||||||
{
|
{
|
||||||
log.Error(ex);
|
log.Error(ex);
|
||||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
log.Error(ex);
|
log.Error(ex);
|
||||||
Respuesta.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
model.CodigoRespuesta = EnumTipoCodigoRespuesta.ERROR.ToString();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Actual = null;
|
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