예제 #1
0
        /// <summary>
        /// 代理等级提升判断并执行
        /// </summary>
        /// <param name="RecomAgent">需要判断升级的代理商</param>
        /// <returns></returns>
        public static bool  IsLevelUpWithCondition(Agent RecomAgent)
        {
            bool result = false;

            using (DistributionContext context = new DistributionContext())
            {
                context.SaveChanges();
                if (RecomAgent.c_agnet_type == (int)AgentType.Exp)
                {
                    return(result);
                }
                int currentLevel = (int)RecomAgent.c_levle;                                                        //当前等级
                int maxLevel     = (int)context.t_level_config.Where(t => t.c_is_delete == 0).Max(t => t.c_level); //当前系统的最高级别
                if (currentLevel == maxLevel)
                {
                    return(result);
                }

                var list = context.t_level_config.Where(f => f.c_is_delete == 0 && f.c_level == (currentLevel + 1));
                if (list.Count() > 0)
                {
                    //升级所需条件配置
                    LevelConfig config      = list.First();
                    var         list_direct = context.t_agent_relation.Where(f => f.c_parent_id == RecomAgent.c_id && f.ChildrenAgent.c_agnet_type != (int)AgentType.Exp);//直推人数
                    if (list_direct.Count() < config.c_need_nums)
                    {
                        result = false;
                    }
                    else
                    {
                        //达到相应等级的人数
                        int levelCount = list_direct.Where(f => f.ChildrenAgent.c_levle >= config.c_need_level && f.ChildrenAgent.c_agnet_type != (int)AgentType.Exp).Count();
                        if (config.c_need_level == null)
                        {
                            RecomAgent.c_levle = currentLevel + 1;
                            AgentLogic.UpdateEntity(RecomAgent);
                            result = true;
                        }
                        else if (levelCount >= config.c_level_num)
                        {
                            RecomAgent.c_levle = currentLevel + 1;
                            AgentLogic.UpdateEntity(RecomAgent);
                            result = true;
                        }
                    }
                }
                var plist = context.t_agent_relation.Where(f => f.c_child_id == RecomAgent.c_id).ToList();
                if (plist.Count() > 0)
                {
                    Agent pAg = plist.FirstOrDefault().ParentAgent;
                    IsLevelUpWithCondition(pAg);
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
예제 #2
0
 public static void DeleteEntity(int ScoreCashId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         ScoreCash DelScoreCash = context.t_score_cash.Find(ScoreCashId);
         context.t_score_cash.Remove(DelScoreCash);
         context.SaveChanges();
     }
 }
예제 #3
0
 public static void DeleteEntity(string CommConfigId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         CommConfig DelCommConfig = context.t_common_config.Find(CommConfigId);
         context.t_common_config.Remove(DelCommConfig);
         context.SaveChanges();
     }
 }
예제 #4
0
 public static void DeleteEntity(string AgentId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         Agent DelAgent = context.t_agent.Find(AgentId);
         context.t_agent.Remove(DelAgent);
         context.SaveChanges();
     }
 }
예제 #5
0
 public static void InsertNewEntiy(CommConfig NewCommConfig)
 {
     using (DistributionContext context = new DistributionContext())
     {
         NewCommConfig.c_id = Guid.NewGuid().ToString();
         context.t_common_config.Add(NewCommConfig);
         context.SaveChanges();
     }
 }
예제 #6
0
 public static void UpdateEntity(LevelConfig UpdateProduct)
 {
     using (DistributionContext context = new DistributionContext())
     {
         LevelConfig ag = context.t_level_config.Find(UpdateProduct.c_id);
         CommLogic.DeepClone <LevelConfig>(ag, UpdateProduct);
         context.SaveChanges();
     }
 }
예제 #7
0
 public static void DeleteEntity(int ProductId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         LevelConfig DelProduct = context.t_level_config.Find(ProductId);
         context.t_level_config.Remove(DelProduct);
         context.SaveChanges();
     }
 }
예제 #8
0
 public static void InsertNewEntiy(LevelConfig NewProduct)
 {
     using (DistributionContext context = new DistributionContext())
     {
         NewProduct.c_id = Guid.NewGuid().ToString();
         context.t_level_config.Add(NewProduct);
         context.SaveChanges();
     }
 }
예제 #9
0
 public static void DeleteEntity(string ScoreDetailId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         ScoreDetail DelScoreDetail = context.t_score_detail.Find(ScoreDetailId);
         context.t_score_detail.Remove(DelScoreDetail);
         context.SaveChanges();
     }
 }
예제 #10
0
 public static void UpdateEntity(ScoreDetail UpdateScoreDetail)
 {
     using (DistributionContext context = new DistributionContext())
     {
         ScoreDetail ag = context.t_score_detail.Find(UpdateScoreDetail.c_id);
         CommLogic.DeepClone <ScoreDetail>(ag, UpdateScoreDetail);
         context.SaveChanges();
     }
 }
예제 #11
0
 public static void UpdateEntity(CommConfig UpdateCommConfig)
 {
     using (DistributionContext context = new DistributionContext())
     {
         CommConfig ag = context.t_common_config.Find(UpdateCommConfig.c_id);
         CommLogic.DeepClone <CommConfig>(ag, UpdateCommConfig);
         context.SaveChanges();
     }
 }
예제 #12
0
 public static void UpdateEntity(AgentRelation UpdateAgentRelation)
 {
     using (DistributionContext context = new DistributionContext())
     {
         AgentRelation ag = context.t_agent_relation.Find(UpdateAgentRelation.c_id);
         CommLogic.DeepClone <AgentRelation>(ag, UpdateAgentRelation);
         context.SaveChanges();
     }
 }
예제 #13
0
 public static void UpdateEntity(ExpApply UpdateExpApply)
 {
     using (DistributionContext context = new DistributionContext())
     {
         ExpApply ag = context.t_exp_apply.Find(UpdateExpApply.F_Id);
         CommLogic.DeepClone <ExpApply>(ag, UpdateExpApply);
         context.SaveChanges();
     }
 }
예제 #14
0
 public static void DeleteEntity(int ProductId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         PublicNotice DelProduct = context.t_public_notice.Find(ProductId);
         context.t_public_notice.Remove(DelProduct);
         context.SaveChanges();
     }
 }
예제 #15
0
 public static void InsertNewEntiy(AgentRelation NewAgentRelation)
 {
     using (DistributionContext context = new DistributionContext())
     {
         NewAgentRelation.c_id = Guid.NewGuid().ToString();
         context.t_agent_relation.Add(NewAgentRelation);
         context.SaveChanges();
     }
 }
예제 #16
0
 public static void InsertNewEntiy(PublicNotice NewProduct)
 {
     using (DistributionContext context = new DistributionContext())
     {
         NewProduct.F_Id = Guid.NewGuid().ToString();
         context.t_public_notice.Add(NewProduct);
         context.SaveChanges();
     }
 }
예제 #17
0
 public static void UpdateEntity(PublicNotice UpdateProduct)
 {
     using (DistributionContext context = new DistributionContext())
     {
         PublicNotice ag = context.t_public_notice.Find(UpdateProduct.F_Id);
         CommLogic.DeepClone <PublicNotice>(ag, UpdateProduct);
         context.SaveChanges();
     }
 }
예제 #18
0
 public static void UpdateEntity(Order UpdateOrder)
 {
     using (DistributionContext context = new DistributionContext())
     {
         Order ag = context.t_order.Find(UpdateOrder.F_Id);
         CommLogic.DeepClone <Order>(ag, UpdateOrder);
         context.SaveChanges();
     }
 }
예제 #19
0
 public static void DeleteEntity(string OrderId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         Order DelOrder = context.t_order.Find(OrderId);
         context.t_order.Remove(DelOrder);
         context.SaveChanges();
     }
 }
예제 #20
0
 public static void DeleteEntity(string ExpApplyId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         ExpApply DelExpApply = context.t_exp_apply.Find(ExpApplyId);
         context.t_exp_apply.Remove(DelExpApply);
         context.SaveChanges();
     }
 }
예제 #21
0
 public static void InsertNewEntiy(ScoreDetail NewScoreDetail)
 {
     using (DistributionContext context = new DistributionContext())
     {
         NewScoreDetail.c_id = Guid.NewGuid().ToString();
         context.t_score_detail.Add(NewScoreDetail);
         context.SaveChanges();
     }
 }
예제 #22
0
 public static void DeleteEntity(string AgentRelationId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         AgentRelation DelAgentRelation = context.t_agent_relation.Find(AgentRelationId);
         context.t_agent_relation.Remove(DelAgentRelation);
         context.SaveChanges();
     }
 }
예제 #23
0
 public static void InsertNewEntiy(ExpApply NewExpApply)
 {
     using (DistributionContext context = new DistributionContext())
     {
         NewExpApply.F_Id          = Guid.NewGuid().ToString();
         NewExpApply.F_CreatorTime = DateTime.Now;
         context.t_exp_apply.Add(NewExpApply);
         context.SaveChanges();
     }
 }
예제 #24
0
 public static void InsertNewEntiy(Order NewOrder)
 {
     using (DistributionContext context = new DistributionContext())
     {
         NewOrder.F_Id          = Guid.NewGuid().ToString();
         NewOrder.F_CreatorTime = DateTime.Now;
         context.t_order.Add(NewOrder);
         context.SaveChanges();
     }
 }
예제 #25
0
        public static void InsertNewEntiy(ScoreCash NewScoreCash)
        {
            using (DistributionContext context = new DistributionContext())
            {
                NewScoreCash.F_Id = Guid.NewGuid().ToString();
                context.t_score_cash.Add(NewScoreCash);
                context.SaveChanges();

            }
        }
예제 #26
0
 public static void UpdateEntity(ScoreCash UpdateScoreCash)
 {
     using (DistributionContext context = new DistributionContext())
     {
         ScoreCash ag = context.t_score_cash.Find(UpdateScoreCash.F_Id);
         CommLogic.DeepClone<ScoreCash>(ag, UpdateScoreCash);
         ag.F_LastModifyTime = DateTime.Now;
         context.SaveChanges();
     }
 }
예제 #27
0
        public List <AuthorizationCode> GetAuthorizationCodes([FromRoute] string routeCode)
        {
            // Verify whether route is not presale
            if (IsPresaleRoute(routeCode))
            {
                // Return empty list
                return(new List <AuthorizationCode>());
            }

            // Query authorization codes from database
            List <AuthorizationCode> authorizationCodes = _context
                                                          .AuthorizationCodes
                                                          .Where(x => x.Route == routeCode)
                                                          .Where(
                x =>
                x.CreatedAt.Year == DateTime.Now.Year &&
                x.CreatedAt.Month == DateTime.Now.Month &&
                x.CreatedAt.Day == DateTime.Now.Day
                )
                                                          .ToList();

            // Verify whether none authorization code is already save in the database
            if (!authorizationCodes.Any())
            {
                // Create authorization codes quantity key
                string AUTHORIZATION_CODES_QUANTITY = "AUTHORIZATION_CODES_QUANTITY";

                // Create authorization codes quantity
                int authorizationCodesQuantity = 30;

                // Get quantity of authorization codes to be created from application settings
                ApplicationSetting applicationSetting = _context
                                                        .ApplicationSettings
                                                        .Where(x => x.Name == AUTHORIZATION_CODES_QUANTITY)
                                                        .FirstOrDefault();

                // Verify whether any application setting was found in the database
                if (applicationSetting != null)
                {
                    authorizationCodesQuantity = Int32.Parse(applicationSetting.Value);
                }

                // Create password options
                PasswordOptions passwordOptions = new PasswordOptions()
                {
                    RequiredLength         = 8,
                    RequiredUniqueChars    = 4,
                    RequireDigit           = true,
                    RequireLowercase       = true,
                    RequireNonAlphanumeric = false,
                    RequireUppercase       = false
                };

                // Iterate through the number of authorization codes to be created
                for (int i = 0; i < authorizationCodesQuantity; i++)
                {
                    // Create a brand new random code by route
                    string randomCode = CreateRandomCode(routeCode, passwordOptions);

                    // Create a new authorization code entity
                    AuthorizationCode authorizationCode = new AuthorizationCode
                    {
                        Code      = randomCode,
                        Route     = routeCode,
                        Status    = Enumerations.Status.Active,
                        CreatedAt = DateTimeOffset.Now
                    };

                    // Add authorization code to database context
                    _context.AuthorizationCodes.Add(authorizationCode);

                    // Save authorization code
                    _context.SaveChanges();

                    // Add new authorization code created to authorization code list
                    authorizationCodes.Add(authorizationCode);
                }
            }

            return(authorizationCodes);
        }