public void saveListDetail(ref LND_ListNumberDetail pList)
 {
     using (var context = new SILOEntities())
     {
         context.LND_ListNumberDetail.Add(pList);
         context.SaveChanges();
     }
 }
 public void saveList(ref LTL_LotteryList pList)
 {
     using (var context = new SILOEntities())
     {
         context.LTL_LotteryList.Add(pList);
         context.SaveChanges();
     }
 }
        public LTD_LotteryDraw getById(long pId)
        {
            LTD_LotteryDraw draw = null;

            using (var context = new SILOEntities())
            {
                draw = context.LTD_LotteryDraw.Find(pId);
            }
            return(draw);
        }
        public List <LTD_LotteryDraw> getAll()
        {
            List <LTD_LotteryDraw> drawList = null;

            using (var context = new SILOEntities())
            {
                drawList = context.LTD_LotteryDraw.ToList();
            }
            return(drawList);
        }
        public LNR_LotteryNumber getByNumberCode(string pNumberCode)
        {
            LNR_LotteryNumber findedNumber = null;

            using (var context = new SILOEntities())
            {
                List <LNR_LotteryNumber> numberlist = context.LNR_LotteryNumber.Where(n => n.LNR_Number.Equals(pNumberCode)).ToList();
                if (numberlist.Count > 0)
                {
                    findedNumber = numberlist[0];
                }
            }
            return(findedNumber);
        }
 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();
         }
     }
 }
        public void saveProhibitedNumbers(int[] pProhibitedArray)
        {
            LNR_LotteryNumber number = null;

            using (var context = new SILOEntities())
            {
                // Determina cual es 1 y cual es 0 en el array de prohibidos y lo guarda en la tabla
                for (int i = 0; i < 100; i++)
                {
                    int positionArray = (i == 0 ? 100 : i);
                    number = context.LNR_LotteryNumber.Find(positionArray);
                    // Actualizar número y estado de sincronización solo si varió el valor
                    if (number.LNR_IsProhibited != pProhibitedArray[i])
                    {
                        number.LNR_IsProhibited    = pProhibitedArray[i];
                        number.SYS_SynchronyStatus = SystemConstants.SYNC_STATUS_PENDING_TO_SERVER;
                    }
                }
                context.SaveChanges();
            }
        }
        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);
        }