public ObjResponse GetListLogsByDate(ObjFilterLogByDate objFilter) { ObjResponse response = new ObjResponse(); try { CultureInfo MyCultureInfo = new CultureInfo("es-CO"); DateTime FecFin = DateTime.ParseExact(objFilter.EndDate, "dd/MM/yyyy", MyCultureInfo); DateTime FecIni = DateTime.ParseExact(objFilter.StarDate, "dd/MM/yyyy", MyCultureInfo); if (FecFin < FecIni) { throw new Exception("La Fecha final no puede ser menor a la fecha inicial"); } response.ListLog = new BOL_Logs().GetListLogs(FecIni, FecFin.AddDays(1), objFilter.Uid); if (response.ListLog != null) { response.Message = "Se consulto con Exito la informacion"; response.Response = true; } else { response.Message = "Se presento un inconveniente consultado la informacion, por favor vuelva a intentar."; response.Response = false; } } catch (Exception ex) { response.Message = "No se pudo completar la peticion. " + ex.Message.ToString(); response.Response = false; } return(response); }
public ObjResponse GetListLogs() { ObjResponse response = new ObjResponse(); try { response.ListLog = new BOL_Logs().GetListLogs(); if (response.ListLog != null) { response.Message = "Se consulto con Exito la informacion"; response.Response = true; } else { response.Message = "Se presento un inconveniente consultado la informacion, por favor vuelva a intentar."; response.Response = false; } } catch (Exception ex) { response.Message = "No se pudo completar la peticion. " + ex.Message.ToString(); response.Response = false; } return(response); }
public ObjResponse InsertLog(Log _objLog) { try { Data.Entities entities = new Data.Entities(); ObjResponse _response = new ObjResponse(); entities.Logs.Add(_objLog); if (entities.SaveChanges() > 0) { _response.Message = "Se inserto Correctamente"; _response.Response = true; } else { _response.Message = "Algo salio mal :( "; _response.Response = false; } return(_response); } catch (Exception ex) { if (!string.IsNullOrWhiteSpace(ex.InnerException.InnerException.Message)) { if (ex.InnerException.InnerException.Message.Contains("FOREIGN KEY")) { throw new Exception("Error de DAL - El UID enviado no corresponde a ningun usuario creado en el sistema."); } else { throw new Exception("Error de DAL -" + ex.InnerException.InnerException.Message); } } else { throw new Exception("Error de DAL -" + ex.Message); } } }