Exemplo n.º 1
0
        void ReleaseDesignerOutlets()
        {
            if (BadgeName != null)
            {
                BadgeName.Dispose();
                BadgeName = null;
            }

            if (BadgeDescription != null)
            {
                BadgeDescription.Dispose();
                BadgeDescription = null;
            }

            if (BadgeImage != null)
            {
                BadgeImage.Dispose();
                BadgeImage = null;
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            //get the current earner  email and id

            var email  = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email).Value;
            var userid = User.Claims.FirstOrDefault(c => c.Type == AppUtility.UserId).Value;

            CollectionView collectionView = new CollectionView(); //initialize the viewmodel

            BadgeExpiryCheck(email);

            //get the info of logged in earner
            var             earnerBadges = EarnerBadgeDetails.Find(e => e.RecipientEmail == email).ToList();
            List <BackPack> list         = new List <BackPack>();

            #region Redis
            var earnerId = await _cache.GetSearchResultAsync(userid);

            if (earnerId != null)
            {
                collectionView.BackPacks = earnerId;
            }

            else
            {
                if (earnerBadges.Count() != null)
                {
                    List <int> add_list = new List <int>();
                    for (var k = 0; k < earnerBadges.Count(); k++)
                    {
                        var badgeid          = earnerBadges[k].BadgeId;
                        var badgedetailsnew  = Badge.Find(e => e.BadgeId == earnerBadges[k].BadgeId).FirstOrDefault();
                        var issuerids        = badgedetailsnew.IssuerId;
                        var issuerdetailsnew = Issuers.Find(e => e.IssuerId == issuerids).FirstOrDefault();
                        var facebookid       = Badge.Find(e => e.BadgeId == badgeid).FirstOrDefault().FacebookId;

                        BackPack b = new BackPack()
                        {
                            BadgeName          = badgedetailsnew.BadgeName,
                            earningDescription = badgedetailsnew.EarningCriteriaDescription,
                            ImageUrl           = badgedetailsnew.ImageUrl,
                            IssuerName         = issuerdetailsnew.Name,
                            badgeid            = badgeid.ToString(),
                            FacebookId         = facebookid,
                            IsExpired          = earnerBadges[k].IsExpired
                        };

                        list.Add(b);
                        DateTime expireDuration = earnerBadges[k].ExpirationDate.Date;
                        DateTime dtNow          = DateTime.Now;
                        TimeSpan result         = expireDuration.Subtract(dtNow);
                        int      seconds        = Convert.ToInt32(result.TotalSeconds);
                        add_list.Add(seconds);
                    }
                    int[] secondsForTotalBadge = add_list.ToArray();

                    if (list.Count > 0)
                    {
                        await _cache.AddSearchResultsAsync(userid, list, secondsForTotalBadge.Min());
                    }
                    collectionView.BackPacks = list;
                }
            }
            #endregion
            collectionView.BadgeCollections = BadgeCollections.Find(e => e.UserId == new ObjectId(userid)).ToList();

            #region showing badge in collection
            var totalBadgeCollection = BadgeCollections.Find(e => e.UserId == new ObjectId(userid)).ToList();
            var totalBadgeImage      = new List <BadgeImage>();
            if (totalBadgeCollection != null)
            {
                for (int badgeColl = 0; badgeColl < totalBadgeCollection.Count; badgeColl++)
                {
                    string[] b = totalBadgeCollection[badgeColl].BadgeId;
                    if (b != null)
                    {
                        for (var n = 0; n < b.Length; n++)
                        {
                            DigiBadges.DataAccess.Badge bdg = _badges.FindById(b[n]);

                            if (b[n].ToString() == bdg.Id.ToString())
                            {
                                BadgeImage badgeImage = new BadgeImage()
                                {
                                    ID       = b[n].ToString(),
                                    ImageUrl = bdg.ImageUrl
                                };
                                totalBadgeImage.Add(badgeImage);
                            }
                        }
                    }
                }
            }
            collectionView.BI = totalBadgeImage;
            #endregion


            return(View(collectionView));
        }
Exemplo n.º 3
0
        public IActionResult Index()
        {
            //get the current earner  email and id

            var email  = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email).Value;
            var userid = User.Claims.FirstOrDefault(c => c.Type == AppUtility.UserId).Value;

            CollectionView collectionView = new CollectionView(); //initialize the viewmodel

            BadgeExpiryCheck(email);

            //get the info of logged in earner
            var earnerBadges = EarnerBadgeDetails.Find(e => e.RecipientEmail == email).ToList();

            List <BackPack> list = new List <BackPack>();

            if (earnerBadges.Count() != null)
            {
                for (var k = 0; k < earnerBadges.Count(); k++)
                {
                    var badgeid          = earnerBadges[k].BadgeId;
                    var badgedetailsnew  = Badge.Find(e => e.BadgeId == earnerBadges[k].BadgeId).FirstOrDefault();
                    var issuerids        = badgedetailsnew.IssuerId;
                    var issuerdetailsnew = Issuers.Find(e => e.IssuerId == issuerids).FirstOrDefault();
                    var facebookid       = Badge.Find(e => e.BadgeId == badgeid).FirstOrDefault().FacebookId;

                    BackPack b = new BackPack()
                    {
                        BadgeName          = badgedetailsnew.BadgeName,
                        earningDescription = badgedetailsnew.EarningCriteriaDescription,
                        ImageUrl           = badgedetailsnew.ImageUrl,
                        IssuerName         = issuerdetailsnew.Name,
                        badgeid            = badgeid,
                        FacebookId         = facebookid,
                        IsExpired          = earnerBadges[k].IsExpired
                    };

                    list.Add(b);
                }
                collectionView.BackPacks = list;
            }

            collectionView.BadgeCollections = BadgeCollections.Find(e => e.UserId == new ObjectId(userid)).ToList();

            #region showing badge in collection
            var totalBadgeCollection = BadgeCollections.Find(e => e.UserId == new ObjectId(userid)).ToList();
            var totalBadgeImage      = new List <BadgeImage>();
            if (totalBadgeCollection != null)
            {
                for (int badgeColl = 0; badgeColl < totalBadgeCollection.Count; badgeColl++)
                {
                    string[] b = totalBadgeCollection[badgeColl].BadgeId;
                    if (b != null)
                    {
                        for (var n = 0; n < b.Length; n++)
                        {
                            DigiBadges.DataAccess.Badge bdg = _badges.FindById(b[n]);

                            if (b[n].ToString() == bdg.Id.ToString())
                            {
                                BadgeImage badgeImage = new BadgeImage()
                                {
                                    ID       = b[n].ToString(),
                                    ImageUrl = bdg.ImageUrl
                                };
                                totalBadgeImage.Add(badgeImage);
                            }
                        }
                    }
                }
            }
            collectionView.BI = totalBadgeImage;
            #endregion


            return(View(collectionView));
        }