Beispiel #1
0
        public JsonResult Update(ValidationSetting validationSetting)
        {
            var validationSettingId = _validationSettingRepository.Update(validationSetting);

            if (validationSetting.ValidationRules != null)
            {
                foreach (var rule in validationSetting.ValidationRules)
                {
                    rule.ValidationSettingId = validationSettingId;

                    if (rule.Id < 0)
                    {
                        _validationRuleRepository.Insert(rule);
                    }
                    else
                    {
                        _validationRuleRepository.Update(rule);
                    }
                }
            }

            _validationResultRepository.SetDisabledBySetting(validationSetting.Id);

            return(Json(validationSetting.Id, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public int Update(ValidationSetting validationSetting)
        {
            using (var model = new gb_dvsstagingEntities())
            {
                val_validationsetting val_Setting = model.val_validationsetting.First(x => x.Id == validationSetting.Id);

                val_Setting.Name        = validationSetting.Name;
                val_Setting.Description = validationSetting.Description;

                val_Setting.PriorityId = validationSetting.PriorityId;
                val_Setting.ProductId  = validationSetting.ProductId;
                val_Setting.Expression = validationSetting.Expression;

                val_Setting.UpdatedBy = "Admin";
                val_Setting.UpdatedOn = DateTime.UtcNow;

                val_Setting.IsSlackEnabled = validationSetting.IsSlackEnabled;
                val_Setting.SlackChannel   = validationSetting.SlackChannel;

                model.Entry(val_Setting).State = EntityState.Modified;

                model.SaveChanges();

                return(val_Setting.Id);
            }
        }
Beispiel #3
0
        public int Insert(ValidationSetting validationSetting)
        {
            using (var model = new gb_dvsstagingEntities())
            {
                var val_valSetting = new val_validationsetting
                {
                    Name        = validationSetting.Name,
                    Description = validationSetting.Description,

                    PriorityId = validationSetting.PriorityId,
                    ProductId  = validationSetting.ProductId,
                    Expression = validationSetting.Expression,

                    CreatedBy = "Admin",
                    CreatedOn = DateTime.UtcNow,

                    UpdatedBy = "Admin",
                    UpdatedOn = DateTime.UtcNow,

                    IsSlackEnabled = validationSetting.IsSlackEnabled,
                    SlackChannel   = validationSetting.SlackChannel,

                    IsActive = true
                };
                model.val_validationsetting.Add(val_valSetting);

                model.SaveChanges();

                return(val_valSetting.Id);
            }
        }
Beispiel #4
0
        public JsonResult Create(ValidationSetting validationSetting)
        {
            var validationSettingId = _validationSettingRepository.Insert(validationSetting);

            if (validationSetting.ValidationRules != null)
            {
                foreach (var rule in validationSetting.ValidationRules)
                {
                    rule.ValidationSettingId = validationSettingId;
                    _validationRuleRepository.Insert(rule);
                }
            }

            return(Json(validationSetting.Id, JsonRequestBehavior.AllowGet));
        }
 public val_validationresult NewRepositoryValidationResultFrom(RuleResultDTO ruleResult, ValidationSetting setting)
 {
     return(new val_validationresult
     {
         EventId = (long)ruleResult.Event.EventId,
         Market = ruleResult.Market,
         Provider = ruleResult.Provider,
         Status = ruleResult.Event.Status,
         ProductId = (int)setting.ProductId,
         LeagueName = ruleResult.Event.LeagueName,
         LeagueId = (long)ruleResult.Event.LeagueId,
         SportId = (long)ruleResult.Event.SportId,
         LocationId = (long)ruleResult.Event.LocationId,
         EventName = ruleResult.Event.BuildEventName(),
         LastUpdate = ruleResult.Event.LastUpdate,
         LocationName = ruleResult.Event.LocationName,
         SportName = ruleResult.Event.SportName,
         ValidationSettingId = setting.Id,
         //XmlMessage = ruleResult.OuterXml,
         CreatedBy = "Admin",
         UpdatedBy = "Admin",
         CreatedOn = DateTime.UtcNow,
         UpdatedOn = DateTime.UtcNow,
         PointsToHighline = ruleResult.PointToHighline.ToString(),
         IsActive = true
     });
 }
        public ValidationResultsHashModel NewRepositoryValidationResultFrom(ArrayList results, ValidationSetting setting, Event @event, string market, string provider)
        {
            var ruleResults = results.Cast <RuleResultDTO>().ToArray();

            ruleResults = ruleResults.DistinctBy(x => x.PointToHighline).ToArray();

            var pointToHighline = "";

            if (setting.IsContainsRuleForAllNodes)
            {
                pointToHighline = string.Join("|",
                                              ruleResults.Where(x => x.IsIssue && x.Rule.IsForAllNodes == false).Select(x => x.PointToHighline.ToString()).Distinct());

                var groupsByNodeName = ruleResults.Where(x => x.IsIssue && x.Rule.IsForAllNodes).GroupBy(x => x.ParentNodeName);

                foreach (var groupByNodeName in groupsByNodeName)
                {
                    var groupsByRuleId = groupByNodeName.GroupBy(x => x.Rule.Id).ToArray();

                    var maxCount = groupsByRuleId.Max(x => x.Count());

                    foreach (var grouping in groupsByRuleId)
                    {
                        if (grouping.Count() == maxCount)
                        {
                            foreach (var ruleResultDto in grouping)
                            {
                                pointToHighline += "|" + ruleResultDto.PointToHighline.ToString();
                            }
                        }
                    }
                }
            }
            else
            {
                pointToHighline = string.Join("|",
                                              ruleResults.Where(x => x.IsIssue).Select(x => x.PointToHighline.ToString()).Distinct());
            }

            string markets   = "";
            string providers = "";

            bool isContainsSingleProvider = true;
            bool isContainsSingleMarket   = true;

            var resultWithMarket = ruleResults.FirstOrDefault(x => x.IsMarket || x.Market != "");

            if (resultWithMarket != null)
            {
                var resultWithProvider = ruleResults.FirstOrDefault(x => x.IsProvider || x.Provider != "");
                if (resultWithProvider != null)
                {
                    markets   = market;
                    providers = provider;
                }
                else
                {
                    isContainsSingleProvider = false;

                    markets = market;

                    // select all providers
                    var bookmakers     = resultWithMarket.ParentXElement.XPathSelectElements(BookmakerName);
                    var withAttributes = bookmakers.Where(x => x.HasAttributes);

                    List <string> names = new List <string>();

                    foreach (var withAttribute in withAttributes)
                    {
                        var nameAttr = withAttribute.Attribute("name");
                        if (nameAttr != null)
                        {
                            names.Add(nameAttr.Value);
                        }
                    }

                    if (names.Count > 0)
                    {
                        providers = string.Join(", ", names);
                    }
                }
            }
            else
            {
                isContainsSingleMarket = false;

                /*
                 * // select all markets and providers
                 * if (@event.MarketNames != null)
                 * {
                 *  markets = string.Join(",", @event.MarketNames.Distinct());
                 * }
                 * if (@event.ProviderNames != null)
                 * {
                 *  providers = string.Join(",", @event.ProviderNames.Distinct());
                 * }
                 */
            }

            var result = new val_validationresult
            {
                EventId             = (long)@event.EventId,
                Status              = @event.Status,
                LeagueName          = @event.LeagueName,
                EventName           = @event.BuildEventName(),
                LastUpdate          = @event.LastUpdate,
                LocationName        = @event.LocationName,
                SportName           = @event.SportName,
                CreatedBy           = "Admin",
                UpdatedBy           = "Admin",
                CreatedOn           = DateTime.UtcNow,
                UpdatedOn           = DateTime.UtcNow,
                ProductId           = (int)setting.ProductId,
                Market              = markets,
                Provider            = providers,
                ValidationSettingId = setting.Id,
                PointsToHighline    = pointToHighline,
                IsActive            = true
            };

            // XmlMessage = string.Join("|", resultsWithoutMarketAndProviderDTO.Select(x => x.OuterXml)),

            if (@event.LeagueId != null)
            {
                result.LeagueId = (long)@event.LeagueId;
            }
            if (@event.SportId != null)
            {
                result.SportId = (long)@event.SportId;
            }
            if (@event.LocationId != null)
            {
                result.LocationId = (long)@event.LocationId;
            }

            return(new ValidationResultsHashModel
            {
                ContainsSingleMarket = isContainsSingleMarket,
                ContainsSingleProvider = isContainsSingleProvider,
                Result = result
            });
        }