public static Ticket GetById(int id) { Ticket ticketResult = null; try { TicketDS ticketDS = new TicketDS(); String objectHash = Guid.NewGuid().ToString(); DataRow dr = ticketDS.GetObjectById(id, objectHash); if (dr != null) { ticketResult = new Ticket(); ticketResult._UObjectID = objectHash; ORM(ticketResult, dr); ticketResult.ObservacionesHistoricas = Observacion.ListByTicket(ticketResult.ID); } } catch (Exception ex) { throw ex; } return(ticketResult); }
public override bool Persist() { bool result = false; try { TicketDS dataservice = new TicketDS(); if (this.Observacion == null) { throw new Exception("El objeto ticket debe tener una observación"); } if (this.IsNew) { this._id = dataservice.Create(this.ObjectToRow(), this.Observacion.ObjectToRow()); result = true; } else { result = dataservice.Update(this.ObjectToRow(), this.Observacion.ObjectToRow()); } } catch (Exception ex) { throw ex; } return(result); }
public static List <Ticket> List(FiltroTicket f, out int RecordCount) { List <Ticket> resultList = new List <Ticket>(); try { TicketDS dataservice = new TicketDS(); DataSet ds = dataservice.List(f, out RecordCount); if (ds.Tables.Count > 0) { foreach (DataRow r in ds.Tables[0].Rows) { Ticket t = new Ticket(); ORM(t, r); resultList.Add(t); } } } catch (Exception ex) { throw ex; } return(resultList); }