Esempio n. 1
0
        public Order(AppUser user, DateTime date)
        {
            this.UserID = user.Id;
            SaleDate = date;

            this.AppUser = user;
        }
Esempio n. 2
0
        public List<NavGrouping> CreateCartControllerNavList(AppUser user)
        {
            List<NavGrouping> grouping = new List<NavGrouping>();

            NavGrouping actions = new NavGrouping();
            actions.GroupingHeader = "Actions";
            actions.NavItems = new List<NavItem>();

            NavItem continueShopping = new NavItem();
            continueShopping.Destination = "/Store";
            continueShopping.DestinationName = "Continue Shopping";

            NavItem clearCart = new NavItem();
            clearCart.Destination = "/Cart/EmptyCart";
            clearCart.DestinationName = "Empty Cart";

            actions.NavItems.Add(continueShopping);
            actions.NavItems.Add(clearCart);

            if (user.AssertValidOrder())
            {
                NavItem purchase = new NavItem();
                purchase.Destination = "/Cart/Purchase";
                purchase.DestinationName = "Purchase";

                actions.NavItems.Add(purchase);
            }

            grouping.Add(actions);

            return grouping;
        }
Esempio n. 3
0
        public UserNotification(AppUser appUser, DateTime dateCreated, string message)
        {
            AppUser = appUser;
            UserID = appUser.Id;

            DateTime = dateCreated;
            IsRead = false;
        }
Esempio n. 4
0
        public BalanceEntry(AppUser user, string notes, int pointsAdjusted, DateTime date)
        {
            Notes = notes;
            PointsAdjusted = pointsAdjusted;
            Date = date;

            UserID = user.Id;
            AppUser = user;
        }
Esempio n. 5
0
        public ShoppingCartEntry(AppUser user, Listing listing, int quantity)
        {
            DateAdded = DateTime.Now;
            this.Quantity = quantity;

            this.ListingID = listing.ListingID;
            this.Listing = listing;

            this.UserID = user.Id;
            this.AppUser = user;
        }
Esempio n. 6
0
        public Mail(AppUser receiver, AppUser sender, string heading, string body, DateTime dateSent)
        {
            AppUserReceiver = receiver;
            ReceiverUserID = receiver.Id;

            AppUserSender = sender;
            SenderUserID = sender.Id;

            Heading = heading;
            Message = body;
            DateSent = dateSent;
        }
Esempio n. 7
0
        public ClaimedProductKey(ProductKey productKey, AppUser user, DateTime? dateAdded, string note)
        {
            ListingID = productKey.ListingID;
            Listing = productKey.Listing;

            Key = productKey.ItemKey;
            Date = dateAdded ?? DateTime.Now;
            IsGift = productKey.IsGift;
            IsUsed = false;
            IsRevealed = false;
            AcquisitionTitle = note;

            UserID = user.Id;
            AppUser = user;
        }
Esempio n. 8
0
        public async Task InsertAppUser(AppUser appUser)
        {
            await userManager.CreateAsync(appUser);

            foreach (BalanceEntry entry in appUser.BalanceEntries)
            {
                if (entry.BalanceEntryID == 0)
                {
                    InsertBalanceEntry(entry);
                }
                else
                {
                    UpdateBalanceEntry(entry);
                }
            }

            foreach (ClaimedProductKey entry in appUser.ClaimedProductKeys)
            {
                if (entry.ClaimedProductKeyID == 0)
                {
                    InsertClaimedProductKey(entry);
                }
                else
                {
                    UpdateClaimedProductKey(entry);
                }
            }
            
            foreach (Mail entry in appUser.ReceivedMail)
            {
                if (entry.MailID == 0)
                {
                    InsertMail(entry);
                }
                else
                {
                    UpdateMail(entry);
                }
            }

            foreach (Order entry in appUser.Orders)
            {
                if (entry.OrderID == 0)
                {
                    InsertOrder(entry);
                }
                else
                {
                    UpdateOrder(entry);
                }
            }

            foreach (OwnedGame entry in appUser.OwnedGames)
            {
                if (entry.OwnedGameID == 0)
                {
                    InsertOwnedGame(entry);
                }
            }

            foreach (UserNotification entry in appUser.UserNotifications)
            {
                if (entry.UserNotificationID == 0)
                {
                    InsertUserNotification(entry);
                }
                else
                {
                    UpdateUserNotification(entry);
                }
            }

            foreach (UserTag entry in appUser.UserTags)
            {
                if (entry.UserTagID == 0)
                {
                    InsertUserTag(entry);
                }
            }
        }
Esempio n. 9
0
 public bool IsWinner(AppUser user)
 {
     return (Winner == null) ? false : Object.Equals(user.Id, Winner.Id);
 }
Esempio n. 10
0
 public bool IsCreator(AppUser user)
 {
     return (Creator == null) ? false : Object.Equals(user.Id, Creator.Id);
 }
Esempio n. 11
0
        public Mail CreateMail(AppUser sender, string heading, string body)
        {
            Mail mail = new Mail(this, sender, heading, body, DateTime.Now);
            CreateUserNotification(mail);

            return mail;
        }
Esempio n. 12
0
        public async Task EditAppUser(AppUser appUser, string roleToAdd, string roleToRemove)
        {
            AppUser updatedUser = UserManager.Users.Where(u => Object.Equals(u.Id, appUser.Id)).SingleOrDefault();

            if (updatedUser == null)
            {
                return;
            }

            updatedUser.Balance = appUser.Balance;
            updatedUser.Nickname = appUser.Nickname;
            updatedUser.UserSteamID = appUser.UserSteamID;
            updatedUser.UserName = appUser.UserName;
            updatedUser.MemberSince = appUser.MemberSince;

            await UserManager.UpdateAsync(updatedUser);

            if (String.IsNullOrEmpty(roleToAdd) == false)
            {
                if (roleToAdd.Contains(","))
                {
                    string[] rolesToAdd = roleToAdd.Split(new char[] { ',' });

                    foreach (string role in rolesToAdd)
                    {
                        await UserManager.AddToRoleAsync(appUser.Id, role);
                    }
                }
                else
                {
                    await UserManager.AddToRoleAsync(appUser.Id, roleToAdd);
                }
            }

            if (String.IsNullOrEmpty(roleToRemove) == false)
            {
                if (roleToRemove.Contains(","))
                {
                    string[] rolesToRemove = roleToRemove.Split(new char[] { ',' });

                    foreach (string role in rolesToRemove)
                    {
                        await UserManager.RemoveFromRoleAsync(appUser.Id, role);
                    }
                }
                else
                {
                    await UserManager.RemoveFromRoleAsync(appUser.Id, roleToRemove);
                }
            }
        }
Esempio n. 13
0
        public async Task CreateAppUser(AppUser appUser, string roleToAdd, string apiKey)
        {
            BuildUser(appUser, apiKey);
            appUser.MemberSince = DateTime.Now;

            await UserManager.CreateAsync(appUser);

            if (String.IsNullOrEmpty(roleToAdd) == false)
            {
                if (roleToAdd.Contains(","))
                {
                    string[] rolesToAdd = roleToAdd.Split(new char[] { ',' });

                    foreach (string role in rolesToAdd)
                    {
                        await UserManager.AddToRoleAsync(appUser.Id, roleToAdd);
                    }
                }
                else
                {
                    await UserManager.AddToRoleAsync(appUser.Id, roleToAdd);
                }
            }
        }
Esempio n. 14
0
 public UserTag(AppUser user, Tag tag)
 {
     this.AppUser = user;
     this.Tag = tag;
 }
Esempio n. 15
0
 public bool IsInRole(AppUser user, string role)
 {
     return UserManager.IsInRole(user.Id, role);
 }
Esempio n. 16
0
        public void BuildUser(AppUser user, string apiKey)
        {
            if (user.UserSteamID == 0)
            {
                // possibly add default data here
                return;
            }

            string playerURL = String.Format("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={0}&steamids={1}&format=json", apiKey, user.UserSteamID);

            string result = new System.Net.WebClient().DownloadString(playerURL);

            JObject playerData = JObject.Parse(result);

            if (playerData["response"] != null && playerData["response"]["players"] != null)
            {
                user.LargeAvatar = (string)playerData["response"]["players"][0]["avatarfull"] ?? "";
                user.MediumAvatar = (string)playerData["response"]["players"][0]["avatarmedium"] ?? "";
                user.SmallAvatar = (string)playerData["response"]["players"][0]["avatar"] ?? "";
            }

            string gamesURL = String.Format("http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key={0}&steamid={1}&format=json", apiKey, user.UserSteamID);

            result = new System.Net.WebClient().DownloadString(gamesURL);

            JObject gameData = JObject.Parse(result);
            
            if (gameData["response"] != null && gameData["response"]["games"] != null)
            {
                JArray jGames = (JArray)gameData["response"]["games"];
                for (int i = 0; i < jGames.Count; i++)
                {
                    user.AddOwnedGame(new OwnedGame((int)jGames[i]["appid"], (int)jGames[i]["playtime_forever"]));
                }
            }

                UserManager.Update(user);
            unitOfWork.Save();            
        }
Esempio n. 17
0
        public List<ActivityFeedContainer> GetPublicActivityFeedItems(AppUser user)
        {
            List<ActivityFeedContainer> activityFeed = new List<ActivityFeedContainer>();

            if (user.CreatedGiveaways != null)
            {
                foreach (Giveaway entry in user.CreatedGiveaways)
                {
                    activityFeed.Add(new ActivityFeedContainer(entry, entry.CreatedTime));
                }
            }

            if (user.GiveawayEntries != null)
            {
                foreach (Giveaway entry in user.WonGiveaways)
                {
                    activityFeed.Add(new ActivityFeedContainer(entry, entry.EndDate));
                }
            }

            if (user.Auctions != null)
            {
                foreach (Auction entry in user.Auctions)
                {
                    activityFeed.Add(new ActivityFeedContainer(entry, entry.CreatedTime));
                }
            }

            if (user.AuctionBids != null)
            {
                foreach (Auction entry in user.AuctionBids.Where(au => Object.Equals(au.Auction.Winner.Id, user.Id)).Select(ab => ab.Auction))
                {
                    activityFeed.Add(new ActivityFeedContainer(entry, entry.EndTime));
                }
            }

            if (user.ProductReviews != null)
            {
                foreach (ProductReview entry in user.ProductReviews)
                {
                    activityFeed.Add(new ActivityFeedContainer(entry));
                }
            }

            return activityFeed.OrderByDescending(a => a.ItemDate).ToList();
        }