Пример #1
0
        public static TotalAward Total(double total, bool isLocked, string compName, ModelsContext context)
        {
            TotalAward totalAward = new TotalAward();

            if (!isLocked)
            {
                var requirements = ReadAwardsRules()["Total"];
                foreach (string req in requirements.Split(','))
                {
                    if (req.Contains("gold"))
                    {
                        totalAward.Gold = total >= int.Parse(req.Split(' ')[1].Trim());
                        if (totalAward.Gold)
                        {
                            NotificationMessages notificationMessages = new NotificationMessages(context);
                            notificationMessages.TotalAwardNotification("gold", compName);
                        }
                        if (totalAward.Gold)
                        {
                            totalAward.GoldRequirementStatus = req.Split(' ')[1].Trim() + " REACHED";
                        }
                        else
                        {
                            totalAward.GoldRequirementStatus = "REACH " + req.Split(' ')[1].Trim();
                        }
                    }
                    else if (req.Contains("silver"))
                    {
                        totalAward.Silver = total >= int.Parse(req.Split(' ')[1].Trim());
                        if (totalAward.Silver)
                        {
                            NotificationMessages notificationMessages = new NotificationMessages(context);
                            notificationMessages.TotalAwardNotification("silver", compName);
                        }
                        if (totalAward.Silver)
                        {
                            totalAward.SilverRequirementStatus = req.Split(' ')[1].Trim() + " REACHED";
                        }
                        else
                        {
                            totalAward.SilverRequirementStatus = "REACH " + req.Split(' ')[1].Trim();
                        }
                    }
                    else
                    {
                        totalAward.Bronze = total >= int.Parse(req.Split(' ')[1].Trim());
                        if (totalAward.Bronze)
                        {
                            NotificationMessages notificationMessages = new NotificationMessages(context);
                            notificationMessages.TotalAwardNotification("bronze", compName);
                        }
                        if (totalAward.Bronze)
                        {
                            totalAward.BronzeRequirementStatus = req.Split(' ')[1].Trim() + " REACHED";
                        }
                        else
                        {
                            totalAward.BronzeRequirementStatus = "REACH " + req.Split(' ')[1].Trim();
                        }
                    }
                }
            }
            else
            {
                var requirements = ReadAwardsRules()["Total"];
                totalAward.Gold = false;
                totalAward.GoldRequirementStatus = "REACH " + requirements.Split(',')[0].Split(' ')[1];
                totalAward.Silver = false;
                totalAward.SilverRequirementStatus = "REACH " + requirements.Split(',')[1].Split(' ')[1];
                totalAward.Bronze = false;
                totalAward.BronzeRequirementStatus = "REACH " + requirements.Split(',')[2].Split(' ')[1];
            }
            return(totalAward);
        }