public LTD_LotteryDraw getById(long pId) { LTD_LotteryDraw draw = null; using (var context = new SILOEntities()) { draw = context.LTD_LotteryDraw.Find(pId); } return(draw); }
public LTD_LotteryDraw getByTypeAndDate(long pDrawType, DateTime?pDrawDate) { LTD_LotteryDraw findedDraw = null; List <LTD_LotteryDraw> drawList = this.getAll().Where( item => item.LDT_LotteryDrawType == pDrawType && item.LTD_CreateDate == pDrawDate ).ToList(); if (drawList.Count > 0) { findedDraw = drawList[0]; } return(findedDraw); }
public void save(ref LTD_LotteryDraw pDraw) { using (var context = new SILOEntities()) { //LTD_LotteryDraw matchingDraw = context.LTD_LotteryDraw.Find(pDraw.LTD_Id); LTD_LotteryDraw matchingDraw = this.getByTypeAndDate(pDraw.LDT_LotteryDrawType, pDraw.LTD_CreateDate); if (matchingDraw != null) { matchingDraw = context.LTD_LotteryDraw.Find(matchingDraw.LTD_Id); matchingDraw.LDS_LotteryDrawStatus = pDraw.LDS_LotteryDrawStatus; context.SaveChanges(); pDraw = matchingDraw; } else { context.LTD_LotteryDraw.Add(pDraw); context.SaveChanges(); } } }
private List <LND_ListNumberDetail> saveList(LotteryListControl pListControl) { LotteryDrawRepository lotteryDrawRepository = new LotteryDrawRepository(); // Crear y guardar nuevo sorteo LTD_LotteryDraw drawToSave = new LTD_LotteryDraw(); drawToSave.LTD_CreateDate = this.drawDate; drawToSave.LDT_LotteryDrawType = this.drawType.LDT_Id; drawToSave.LDS_LotteryDrawStatus = SystemConstants.DRAW_STATUS_OPENED; lotteryDrawRepository.save(ref drawToSave); // Crear y guardar nueva lista LTL_LotteryList listToSave = new LTL_LotteryList(); listToSave.LPS_LotteryPointSale = UtilityService.getPointSale().LPS_Id; listToSave.LTD_LotteryDraw = drawToSave.LTD_Id; listToSave.LTL_CustomerName = this.customerName; this.printDate = DateTime.Now; listToSave.LTL_CreateDate = this.printDate; listToSave.LLS_LotteryListStatus = SystemConstants.LIST_STATUS_CREATED; listToSave.SYS_SynchronyStatus = SystemConstants.SYNC_STATUS_PENDING_TO_SERVER; lotteryDrawRepository.saveList(ref listToSave); this.list = listToSave; // Crear colección y guardar a nivel local detalle de números de la lista List <LND_ListNumberDetail> numberDetailCollection = new List <LND_ListNumberDetail>(); LotteryNumberRepository numberRepository = new LotteryNumberRepository(); foreach (var register in pListControl.loteryList.tupleList) { LND_ListNumberDetail newListNumberDetail = new LND_ListNumberDetail(); newListNumberDetail.LTL_LotteryList = listToSave.LTL_Id; newListNumberDetail.LND_Id = register.Key; newListNumberDetail.LNR_LotteryNumber = numberRepository.getByNumberCode(register.Value.number).LNR_Id; newListNumberDetail.LND_SaleImport = register.Value.import; lotteryDrawRepository.saveListDetail(ref newListNumberDetail); numberDetailCollection.Add(newListNumberDetail); } // Almacenar la colección de números generada //this.numberDetail = numberDetailCollection; return(numberDetailCollection); }
public LTD_LotteryDraw getDrawRegister(LTD_LotteryDraw pDraw) { LTD_LotteryDraw findedDraw = null; using (var context = new SILOEntities()) { if (pDraw.LTD_Id != 0) { findedDraw = context.LTD_LotteryDraw.Find(pDraw.LTD_Id); } else { List <LTD_LotteryDraw> drawList = context.LTD_LotteryDraw .Where(list => list.LTD_CreateDate == pDraw.LTD_CreateDate) .Where(list => list.LDT_LotteryDrawType == pDraw.LDT_LotteryDrawType) .ToList(); if (drawList.Count > 0) { findedDraw = drawList[0]; } } } return(findedDraw); }