/// <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); }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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); }