public void saveListDetail(ref LND_ListNumberDetail pList) { using (var context = new SILOEntities()) { context.LND_ListNumberDetail.Add(pList); 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); }