Ejemplo n.º 1
0
        public static HoursAward Hours(string token, ModelsContext context)
        {
            var hoursRecord = context.TimeSpents
                              .FirstOrDefault(x => x.User.Token == token);
            NotificationMessages notificationMessages = new NotificationMessages(context);

            HoursAward hours = new HoursAward {
                Gold             = false,
                Bronze           = false,
                Silver           = false,
                Hours            = 0,
                MembershipNumber = context.Users.Where(x => x.Token == token).First().MemberID,
                Username         = context.Users.Where(x => x.Token == token).First().Username
            };

            //Has not added any score in skietbaan
            if (hoursRecord == null)
            {
                return(hours);
            }

            hours.Hours = hoursRecord.HoursSpent;
            //MAKE THIS DYNAMIC
            if (hours.Hours >= 5)
            {
                hours.Bronze = true;
                notificationMessages.HoursAwardNotification("bronze");
            }
            if (hours.Hours >= 10)
            {
                hours.Silver = true;
                notificationMessages.HoursAwardNotification("silver");
            }
            if (hours.Hours >= 15)
            {
                hours.Gold = true;
                notificationMessages.HoursAwardNotification("gold");
            }

            return(hours);
        }