public static Recuperacion GetRecuperacionByUsuarioById(int UsuarioID) { if (UsuarioID <= 0) { throw new ArgumentException("Id con valor invalido"); } DAL.RecuperacionDSTableAdapters.RecuperacionTableAdapter adapter = new DailyDB.App_Code.DAL.RecuperacionDSTableAdapters.RecuperacionTableAdapter(); RecuperacionDS.RecuperacionDataTable table = adapter.GetRecuperacionByUsuarioId(UsuarioID); if (table.Rows.Count == 0) { return(null); } Recuperacion obj = GetRecuperacionFromRow(table[0]); return(obj); }
public static int InsertRecuperacion(string email) { if (string.IsNullOrEmpty(email)) { throw new ArgumentException("valores no validos"); } DateTime fechaAct = DateTime.Now; Usuario usuario = UsuarioBRL.GetUsuarioByEmail(email); String codigo = GetCodigo(); DateTime fechaExp = fechaAct.AddHours(12); int? RecuperacionId = null; DailyDB.App_Code.DAL.RecuperacionDSTableAdapters.RecuperacionTableAdapter adapter = new DailyDB.App_Code.DAL.RecuperacionDSTableAdapters.RecuperacionTableAdapter(); adapter.Insert(codigo, fechaAct, fechaExp, usuario.UsuarioID, ref RecuperacionId); if (RecuperacionId == null || RecuperacionId.Value <= 0) { throw new Exception("La llave primaria no se generó correctamente"); } return(RecuperacionId.Value); }
public static void DeleteRecuperacion(int RecupId) { if (RecupId <= 0) { throw new ArgumentException("Id con valor invalido"); } DailyDB.App_Code.DAL.RecuperacionDSTableAdapters.RecuperacionTableAdapter adapter = new DailyDB.App_Code.DAL.RecuperacionDSTableAdapters.RecuperacionTableAdapter(); adapter.Delete(RecupId); }
public static Recuperacion GetRecupByIdUserAndCodigo(int idUser, string codigo) { if (idUser <= 0 || string.IsNullOrEmpty(codigo)) { throw new ArgumentException("Id y codigo con valor invalido"); } DailyDB.App_Code.DAL.RecuperacionDSTableAdapters.RecuperacionTableAdapter adapter = new DailyDB.App_Code.DAL.RecuperacionDSTableAdapters.RecuperacionTableAdapter(); RecuperacionDS.RecuperacionDataTable table = adapter.GetRecuperacionByCodigoAndUserID(codigo, idUser); if (table.Rows.Count == 0) { return(null); } Recuperacion obj = GetRecuperacionFromRow(table[0]); return(obj); }