public LPF_LotteryPrizeFactor saveByPointSaleAndDraw(LPF_LotteryPrizeFactor pPrizeFactor)
        {
            LPF_LotteryPrizeFactor findedEntity = null;

            using (var context = new SILOEntities())
            {
                if (pPrizeFactor.LPF_Id != 0)
                {
                    findedEntity = this.getByPointSaleAndGroup(pPrizeFactor.LPS_LotteryPointSale, pPrizeFactor.LDT_LotteryDrawType);
                    if (findedEntity == null)
                    {
                        // Si no existe la entidad, añadirla y guardar cambios
                        context.LPF_LotteryPrizeFactor.Add(pPrizeFactor);
                        context.SaveChanges();
                        findedEntity = pPrizeFactor;
                    }
                    else
                    {
                        findedEntity = context.LPF_LotteryPrizeFactor.Find(findedEntity.LPF_Id);
                        long actualStatus = findedEntity.copy(pPrizeFactor);
                        // Validar estado de la entidad para determinar si se actualiza
                        if (actualStatus == SystemConstants.SYNC_STATUS_COMPLETED)
                        {
                            // Update solamente si el estado es completamente sincronizado
                            context.SaveChanges();
                        }
                    }
                }
            }
            return(findedEntity);
        }
Exemple #2
0
        // Save
        public DataType saveWithStatus(DataType pEntityInstance, KeyType pEntityId, Func <DataType, DataType, long> pCopyFuntion)
        {
            DataType findedEntity = null;

            using (var context = new SILOEntities())
            {
                if (pEntityId != default(KeyType))
                {
                    // Validar colecciones vacías y elementos no encontrados
                    var entityCollection = context.Set <DataType>();
                    findedEntity = entityCollection.Count() == 0 ? null : entityCollection.Find(pEntityId);
                    if (findedEntity == null)
                    {
                        // Si no existe la entidad, añadirla y guardar cambios
                        context.Set <DataType>().Add(pEntityInstance);
                        context.SaveChanges();
                        findedEntity = pEntityInstance;
                    }
                    else
                    {
                        long actualStatus = pCopyFuntion(findedEntity, pEntityInstance);
                        context.SaveChanges();
                    }
                }
            }
            return(findedEntity);
        }
Exemple #3
0
        // Save
        public DataType save(DataType pEntityInstance, KeyType pEntityId, Func <DataType, DataType, long> pCopyFuntion)
        {
            DataType findedEntity = null;

            using (var context = new SILOEntities())
            {
                if (pEntityId != default(KeyType))
                {
                    // Validar colecciones vacías y elementos no encontrados
                    var entityCollection = context.Set <DataType>();
                    findedEntity = entityCollection.Count() == 0 ? null : entityCollection.Find(pEntityId);
                    if (findedEntity == null)
                    {
                        // Si no existe la entidad, añadirla y guardar cambios
                        context.Set <DataType>().Add(pEntityInstance);
                        context.SaveChanges();
                        findedEntity = pEntityInstance;
                    }
                    else
                    {
                        long actualStatus = pCopyFuntion(findedEntity, pEntityInstance);
                        // Validar estado de la entidad para determinar si se actualiza
                        //if (actualStatus == SystemConstants.SYNC_STATUS_COMPLETED)
                        if (actualStatus != SystemConstants.SYNC_STATUS_PENDING_TO_SERVER)
                        {
                            // Update solamente si el estado es completamente sincronizado
                            context.SaveChanges();
                        }
                    }
                }
            }
            return(findedEntity);
        }
Exemple #4
0
        public CPN_Company save(CPN_Company pCompany)
        {
            CPN_Company findedCompany = null;

            using (var context = new SILOEntities())
            {
                if (pCompany.CPN_Id != 0)
                {
                    findedCompany = context.CPN_Company.Find(pCompany.CPN_Id);
                    if (findedCompany == null)
                    {
                        findedCompany = pCompany;
                        context.CPN_Company.Add(pCompany);
                    }
                    else
                    {
                        findedCompany.CPN_Code        = pCompany.CPN_Code;
                        findedCompany.CPN_DisplayName = pCompany.CPN_DisplayName;
                        findedCompany.CPN_Description = pCompany.CPN_Description;
                    }
                    context.SaveChanges();
                }
            }
            return(findedCompany);
        }
        public void save(SPR_ServerParameter pParam)
        {
            SPR_ServerParameter parameter = null;

            using (var context = new SILOEntities())
            {
                List <SPR_ServerParameter> paramList = context.SPR_ServerParameter
                                                       .Where(param => param.SPR_Name == pParam.SPR_Name).ToList();
                if (paramList.Count > 0)
                {
                    parameter = paramList[0];
                }
                if (parameter == null)
                {
                    parameter           = new SPR_ServerParameter();
                    parameter.SPR_Id    = pParam.SPR_Id;
                    parameter.SPR_Name  = pParam.SPR_Name;
                    parameter.SPR_Value = pParam.SPR_Value;
                    context.Set <SPR_ServerParameter>().Add(parameter);
                }
                else
                {
                    parameter.SPR_Value = pParam.SPR_Value;
                }
                context.SaveChanges();
            }
        }
Exemple #6
0
        public void save(ref DNW_DrawNumberWinning pDrawWinning)
        {
            DNW_DrawNumberWinning matchingDrawWinning = this.getDrawWinningRegister(pDrawWinning);

            if (matchingDrawWinning == null)
            {
                using (var context = new SILOEntities())
                {
                    context.DNW_DrawNumberWinning.Add(pDrawWinning);
                    context.SaveChanges();
                }
            }
            else
            {
                using (var context = new SILOEntities())
                {
                    matchingDrawWinning = context.DNW_DrawNumberWinning.Find(pDrawWinning.LTD_LotteryDraw);
                    matchingDrawWinning.DNW_FirtsNumber     = pDrawWinning.DNW_FirtsNumber;
                    matchingDrawWinning.DNW_SecondNumber    = pDrawWinning.DNW_SecondNumber;
                    matchingDrawWinning.DNW_ThirdNumber     = pDrawWinning.DNW_ThirdNumber;
                    matchingDrawWinning.DNW_CreateDate      = pDrawWinning.DNW_CreateDate;
                    matchingDrawWinning.SYS_SynchronyStatus = pDrawWinning.SYS_SynchronyStatus;
                    context.SaveChanges();
                }
            }
        }
        public void save(LPR_LocalParameter pParam)
        {
            LPR_LocalParameter parameter = null;

            using (var context = new SILOEntities())
            {
                List <LPR_LocalParameter> paramList = context.LPR_LocalParameter
                                                      .Where(param => param.LPR_Name == pParam.LPR_Name).ToList();
                if (paramList.Count > 0)
                {
                    parameter = paramList[0];
                }
                if (parameter == null)
                {
                    parameter           = new LPR_LocalParameter();
                    parameter.LPR_Name  = pParam.LPR_Name;
                    parameter.LPR_Value = pParam.LPR_Value;
                    parameter.LPT_LocalParameterType = pParam.LPT_LocalParameterType;
                    context.LPR_LocalParameter.Add(parameter);
                }
                else
                {
                    parameter.LPT_LocalParameterType = pParam.LPT_LocalParameterType;
                    parameter.LPR_Value = pParam.LPR_Value;
                }
                context.SaveChanges();
            }
        }
Exemple #8
0
        public void updateList(LTL_LotteryList pList)
        {
            LTL_LotteryList list = null;

            using (var context = new SILOEntities())
            {
                list = context.LTL_LotteryList.Find(pList.LTL_Id);
                list.LTL_CreateDate        = pList.LTL_CreateDate;
                list.LTL_CustomerName      = pList.LTL_CustomerName;
                list.LLS_LotteryListStatus = pList.LLS_LotteryListStatus;
                list.SYS_SynchronyStatus   = pList.SYS_SynchronyStatus;
                context.SaveChanges();
            }
        }