public int Create(Empleado_Infonavit model, int idUser) { if (model.TipoCredito == 4) { model.UsarUMA = true; model.TipoCredito = 4; } else { model.UsarUMA = false; } model.Status = true; model.FechaReg = DateTime.Now; model.IdUsuarioReg = idUser; using (var context = new RHEntities()) { context.Empleado_Infonavit.Add(model); var status = context.SaveChanges(); if (status > 0) { Notificaciones.INFONAVIT(model, "Nuevo Crédito"); return(model.Id); } return(0); } }
public int Create(Empleado_Infonavit model) { if (model.TipoCredito == 4) { model.UsarUMA = true; model.TipoCredito = 4; } else { model.UsarUMA = false; } model.Status = true; ctx.Empleado_Infonavit.Add(model); var status = ctx.SaveChanges(); if (status > 0) { Notificaciones.INFONAVIT(model, "Nuevo Crédito"); return(model.Id); } return(0); }
public int Update(Empleado_Infonavit newModel, int idUser) { using (var context = new RHEntities()) { var title = "Actualización de Crédito"; if (newModel.FechaSuspension != null) { newModel.Status = false; title = "Suspensión de Crédito"; } var old = context.Empleado_Infonavit.FirstOrDefault(x => x.Id == newModel.Id); if (old == null) { return(0); } old.NumCredito = newModel.NumCredito; old.TipoCredito = newModel.TipoCredito; old.FactorDescuento = newModel.FactorDescuento; //old.Salario = newModel.Salario; old.FechaInicio = newModel.FechaInicio; old.FechaSuspension = newModel.FechaSuspension; old.UsarUMA = newModel.TipoCredito == 4;//VSM UMA old.Status = newModel.Status; old.FechaMod = DateTime.Now; old.IdUsuarioMod = idUser; var status = context.SaveChanges(); if (status > 0) { Notificaciones.INFONAVIT(newModel, title); return(newModel.Id); } return(0); } }