public virtual async Task <ActionResult> Index()
        {
            var leaderboardCollection = await LeaderboardCollection.GetLeaderboardAsync();

            var leaderboardIndexViewModel = new LeaderboardIndexViewModel();
            var allBadges = await BadgeCollection.GetAllBadgesByTypeAsync(BadgeType.Unset);

            leaderboardIndexViewModel.TopTenCorporateBadgeHolders = leaderboardCollection
                                                                    .OrderByDescending(li => li.EarnedCorporateBadgeCount)
                                                                    .Take(10);

            leaderboardIndexViewModel.TopTenCommunityBadgeHolders = leaderboardCollection
                                                                    .OrderByDescending(li => li.EarnedCommunityBadgeCount)
                                                                    .Take(10);

            leaderboardIndexViewModel.TotalCorporateBadgeCount = allBadges
                                                                 .Where(bi => bi.Type == BadgeType.Corporate)
                                                                 .Count();

            leaderboardIndexViewModel.TotalCommunityBadgeCount = allBadges
                                                                 .Where(bi => bi.Type == BadgeType.Community)
                                                                 .Count();

            return(View(leaderboardIndexViewModel));
        }
Esempio n. 2
0
        public async virtual Task <ActionResult> Index()
        {
            var allBadges = await BadgeCollection.GetAllBadgesByTypeAsync(BadgeType.Unset);

            var allEarnedBadges = await EarnedBadgeCollection.GetAllBadgesForUserByTypeAsync(AuthenticatedUser.EmployeeId, BadgeType.Unset);

            var allActivities = await ActivityCollection.GetAllActivitiesAsync(true);

            var corporateBadges       = allBadges.Where(b => b.Type == BadgeType.Corporate);
            var communityBadges       = allBadges.Where(b => b.Type == BadgeType.Community);
            var earnedCorporateBadges = allEarnedBadges.Where(b => b.Type == BadgeType.Corporate);
            var earnedCommunityBadges = allEarnedBadges.Where(b => b.Type == BadgeType.Community);

            var sortedCorporateBadges = corporateBadges.OrderByDescending(b => b.BadgePriority);
            var sortedCommunityBadges = communityBadges.OrderByDescending(b => b.BadgePriority);
            var badgeIndexViewModel   = new BadgeIndexViewModel()
            {
                CorporateBadges       = sortedCorporateBadges,
                CorporateEarnedBadges = earnedCorporateBadges,
                CommunityBadges       = sortedCommunityBadges,
                CommunityEarnedBadges = earnedCommunityBadges,
                SubmittedActivity     = SubmitActivity.CreateActivitySubmission(AuthenticatedUser.EmployeeId),
                AvailableUsers        = await UserCollection.GetAllAvailabileUsersForCurrentUserAsync(),
            };

            badgeIndexViewModel.AllActivities      = allActivities;
            badgeIndexViewModel.PossibleActivities = allActivities.Select(ai => new SelectListItem()
            {
                Text = ai.Name, Value = ai.Id.ToString(CultureInfo.CurrentCulture)
            });

            return(View(badgeIndexViewModel));
        }
Esempio n. 3
0
        private void SlideOut()
        {
            //DismissToolTips();
            int devId = int.Parse(DevName.Text);

            if (devId == _selectedDevId)
            {
                BadgeCollection.TranslateTo(150, 0);
            }
        }
        /// <summary>
        /// Gets the minimum and optional maximum badge value.
        /// </summary>
        /// <param name="BadgeName">Name of the badge to get the value for.</param>
        /// <returns></returns>
        public async virtual Task <string> MaxAwardValue(string BadgeName)
        {
            var allActivities = await ActivityCollection.GetAllActivitiesAsync(false);

            var activityIds = allActivities.Where(x => x.Name == BadgeName).Select(x => x.Id);
            var allBadges   = await BadgeCollection.GetAllBadgesForActivitiesAsync(activityIds);

            var Badge       = allBadges.Select(x => new { x.Id, x.BadgeAwardValue, x.BadgeAwardValueMax }).FirstOrDefault();
            var valueObject = new { minval = Badge.BadgeAwardValue, maxval = Badge.BadgeAwardValueMax };

            return(Newtonsoft.Json.JsonConvert.SerializeObject(valueObject));;
        }
Esempio n. 5
0
        private void AddBadge()
        {
            var element = DefaultManager.Instance.DefaultBadge;

            DataManager.Instance.AddBadge(element);

            var vm = new BadgeViewModel(element);

            BadgeCollection.Add(vm);
            OnPropertyChanged("BadgeCollection");
            CurrentBadge = vm;
        }
Esempio n. 6
0
        public async virtual Task <ActionResult> SubmitActivityForm()
        {
            var submittedActivity = SubmitActivity.CreateActivitySubmission(AuthenticatedUser.EmployeeId);

            TryUpdateModel(submittedActivity, "SubmittedActivity");
            var activities = await ActivityCollection.GetAllActivitiesAsync(false);

            var badges = await BadgeCollection.GetAllBadgesForActivitiesAsync(activities.Where(x => x.Id == submittedActivity.ActivityId).Select(x => x.Id));

            var badge = badges.Select(x => new { x.Id, x.BadgeAwardValue, x.BadgeAwardValueMax }).FirstOrDefault();

            if (submittedActivity.AwardValue > badge.BadgeAwardValueMax || submittedActivity.AwardValue < badge.BadgeAwardValue)
            {
                ModelState.AddModelError("SubmittedActivity.AwardValue", String.Format("Award Value not within acceptable range. ({0} - {1})", badge.BadgeAwardValue, badge.BadgeAwardValueMax));
            }
            else if (string.IsNullOrWhiteSpace(submittedActivity.EmployeeIds))
            {
                ModelState.AddModelError("SubmittedActivity.EmployeeIds", ApplicationResources.NoEmployeeIdsErrorMsg);
            }
            else
            {
                //Parse the list of employee ids the client form sent us.
                List <int> empIds = submittedActivity.EmployeeIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                    .Convert(delegate(string item, out int result) { return(int.TryParse(item.Trim(), out result)); });

                bool allSaved = true;
                foreach (int empId in empIds)
                {
                    var singleActivity = SubmitActivity.CreateActivitySubmission(empId);
                    singleActivity.ActivityId             = submittedActivity.ActivityId;
                    singleActivity.ActivitySubmissionDate = submittedActivity.ActivitySubmissionDate;
                    singleActivity.Notes      = submittedActivity.Notes;
                    singleActivity.AwardValue = submittedActivity.AwardValue;

                    var singActEdit = await ActivityEdit.GetActivityEditByIdAsync(singleActivity.ActivityId);

                    singleActivity.EntryType = singActEdit.EntryType;
                    if (!await SaveObjectAsync(singleActivity, true))
                    {
                        allSaved = false;
                    }
                }

                if (allSaved)
                {
                    return(RedirectToAction(await Mvc.Activities.Actions.Index()));
                }
            }

            return(await Index());
        }
        public async virtual Task <ActionResult> Index()
        {
            var corporateBadges = await BadgeCollection.GetAllBadgesByTypeAsync(BadgeType.Corporate);

            var communityBadges = await BadgeCollection.GetAllBadgesByTypeAsync(BadgeType.Community);

            var badgeManagerIndexViewModel = new BadgeManagerIndexViewModel()
            {
                CorporateBadges = corporateBadges,
                CommunityBadges = communityBadges,
            };

            return(View(badgeManagerIndexViewModel));
        }
        public virtual async Task <ActionResult> Compare(string userName)
        {
            var leftLeaderboardItem = await LeaderboardItem.GetLeaderboardForUserName(AuthenticatedUser.UserName);

            var rightLeaderboardItem = await LeaderboardItem.GetLeaderboardForUserName(userName);

            var allBadges = await BadgeCollection.GetAllBadgesByTypeAsync(BadgeType.Unset);

            var allActivities = await ActivityCollection.GetAllActivitiesAsync(false);

            var leaderboardCompareViewModel = new LeaderboardCompareViewModel();

            leaderboardCompareViewModel.LeftLeaderboardItem  = leftLeaderboardItem;
            leaderboardCompareViewModel.RightLeaderboardItem = rightLeaderboardItem;
            leaderboardCompareViewModel.AllBadges            = allBadges;
            leaderboardCompareViewModel.AllActivities        = allActivities;

            return(View(leaderboardCompareViewModel));
        }
Esempio n. 9
0
        private void AddNewQuestion(Window window)
        {
            Random rand = new Random();
            Task   task = new Task(() =>
            {
                BadgeCollection Badges = new BadgeCollection()
                {
                    GoldenBadges = rand.Next(0, 10),
                    SilverBadges = rand.Next(0, 50),
                    BronzeBadges = rand.Next(0, 200)
                };

                User Owner = new User()
                {
                    Name       = questionAuthor,
                    Reputation = rand.Next(0, 10000),
                };
                Owner.BadgeCollection = Badges;

                Topic newTopic = new Topic()
                {
                    Title        = questionTitle,
                    Content      = questionContent,
                    StringTags   = questionTags,
                    VoteCount    = rand.Next(0, 100),
                    AnswerCount  = rand.Next(0, 50),
                    ViewCount    = rand.Next(0, 10000),
                    CreationDate = 0
                };
                newTopic.User = Owner;

                DataBaseRepository.AddNewTopic(newTopic);
            });

            task.Start();

            if (window != null)
            {
                window.Close();
            }
        }
Esempio n. 10
0
 private void RemoveBadge()
 {
     DataManager.Instance.RemoveBadge(CurrentBadge.Model);
     BadgeCollection.Remove(CurrentBadge);
     OnPropertyChanged("CurrentBadge");
 }
        /// <summary>
        /// Convert dashboard business entity to Model
        /// </summary>
        /// <param name="argDashboardBE">Dashboard business Entity</param>
        /// <returns></returns>
        private Dashboard ConvertDashboardBEDataToModel(DashboardBE argDashboardBE)
        {
            #region Declarations
            Dashboard              l_Dashboard              = new Dashboard();
            SkillCollection        l_SkillCollection        = new SkillCollection();
            BadgeCollection        l_BadgeCollection        = new BadgeCollection();
            ScheduleDemoCollection l_ScheduleDemoCollection = new ScheduleDemoCollection();
            Badge        l_Badge;
            Skills       l_Skills;
            ScheduleDemo l_ScheduleDemo;
            #endregion
            try
            {
                if (argDashboardBE != null)
                {
                    //Get User Details
                    l_Dashboard.UserID             = argDashboardBE.UserID;
                    l_Dashboard.UserName           = argDashboardBE.UserName;
                    l_Dashboard.EmailID            = argDashboardBE.EmailID;
                    l_Dashboard.InitialSkillExists = argDashboardBE.InitialSkillExists;
                    l_Dashboard.DisplayActionItems = argDashboardBE.UserID == GetLoggedInUserID() ? true : false;


                    //Convert Skill and subskill set
                    if (argDashboardBE.SkillsBECollection != null && argDashboardBE.SkillsBECollection.Count > 0)
                    {
                        foreach (var skill in argDashboardBE.SkillsBECollection)
                        {
                            l_Skills                    = new Skills();
                            l_Skills.SkillID            = skill.SkillID;
                            l_Skills.SkillName          = skill.SkillName;
                            l_Skills.SkillType          = skill.SkillType;
                            l_Skills.SkillPoints        = skill.SkillPoints;
                            l_Skills.SubSkillCollection = GetSubskillcollection(skill.SubSkillBECollection);

                            l_SkillCollection.Add(l_Skills);
                        }

                        l_Dashboard.SkillsCollection = l_SkillCollection;


                        l_Dashboard.SkillData = JsonConvert.SerializeObject(l_SkillCollection);
                    }

                    //Convert Badge
                    if (argDashboardBE.BadgeBECollection != null && argDashboardBE.BadgeBECollection.Count > 0)
                    {
                        foreach (var badgeBE in argDashboardBE.BadgeBECollection)
                        {
                            l_Badge            = new Badge();
                            l_Badge.BadgeID    = badgeBE.BadgeID;
                            l_Badge.BadgeName  = badgeBE.BadgeName;
                            l_Badge.BadgeURL   = badgeBE.BadgeURL;
                            l_Badge.BadgeCount = badgeBE.BadgeCount;

                            l_BadgeCollection.Add(l_Badge);
                        }

                        l_Dashboard.BadgeCollection = l_BadgeCollection;
                    }

                    //Convert Demo Details
                    if (argDashboardBE.ScheduleDemoBECollection != null && argDashboardBE.ScheduleDemoBECollection.Count > 0)
                    {
                        foreach (var demoBE in argDashboardBE.ScheduleDemoBECollection)
                        {
                            l_ScheduleDemo = new ScheduleDemo();
                            l_ScheduleDemo.DemoSchedule     = demoBE.DemoSchedule;
                            l_ScheduleDemo.Comments         = demoBE.Comments;
                            l_ScheduleDemo.UniqueID         = demoBE.UniqueID;
                            l_ScheduleDemo.Room             = demoBE.Room;
                            l_ScheduleDemo.SkillID          = demoBE.SkillID;
                            l_ScheduleDemo.SkillName        = demoBE.SkillName;
                            l_ScheduleDemo.SubSkillName     = demoBE.SubSkillName;
                            l_ScheduleDemo.UserID           = demoBE.UserID;
                            l_ScheduleDemo.EventConductedBy = demoBE.EventConductedBy;

                            l_ScheduleDemoCollection.Add(l_ScheduleDemo);
                        }

                        l_Dashboard.ScheduleDemoCollection = l_ScheduleDemoCollection;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(l_Dashboard);
        }