public int AgregaSorteo() { try { Premio = new PremioDTO(); Cliente = new ClientesDTO(); Voucher = new VoucherDTO(); Premio.IdPremio = this.premioid; Cliente.Clienteid = this.clienteid; Voucher.IdVoucher = this.voucherid; if (Premio.GetPremioByID() && Cliente.GetClientByID() && (Voucher.GetVoucherById() == 0)) { SorteoDTO sorteo = new SorteoDTO(); sorteo.Clienteid = this.clienteid; sorteo.IdPremio = this.premioid; sorteo.IdVoucher = this.voucherid; this.IdSorteo = sorteo.addSorteo(); if (this.IdSorteo != -1) { return(IdSorteo); } } } catch (Exception ex) { return(-1); } return(-1); }
public List <PremioDTO> FromRowsToList(DataTable premios) { List <PremioDTO> premiosDTO = new List <PremioDTO>(); foreach (DataRow row in premios.Rows) { PremioDTO premioDTO = new PremioDTO(); premioDTO.Amount = Convert.ToInt32(row["Cantidad"]); premioDTO.Descripcion = Convert.ToString(row["Descripcion"]); premioDTO.Puntos = Convert.ToInt32(row["Puntos"]); premiosDTO.Add(premioDTO); } return(premiosDTO); }
// Busca el premio por iD devuelve true si lo encuentra public bool GetPremioByID() { PremioDTO premio = new PremioDTO(); premio.IdPremio = this.IdPremio; if (premio.GetPremioByID()) { this.Descripcion = premio.Descripcion; this.URL = premio.URL; return(true); } else { return(false); } }
// Retorna una lista con todos los premios que existen en la base // si no los hay retorna null public List <PremioNegocio> GetPremios() { List <PremioDTO> premiolist = new List <PremioDTO>(); List <PremioNegocio> premioReturn = new List <PremioNegocio>(); PremioDTO obj = new PremioDTO(); premiolist = obj.GetPremios(); if (premiolist != null) { foreach (var foo in premiolist) { this.IdPremio = foo.IdPremio; this.Descripcion = foo.Descripcion; this.URL = foo.URL; premioReturn.Add(new PremioNegocio(this)); } return(premioReturn); } return(null); }