コード例 #1
0
ファイル: AdminController.cs プロジェクト: jefking/Borentra
        //
        // GET: /Admin/Users
        public ActionResult Users(Guid?id, short count = 10)
        {
            if (id.HasValue && Guid.Empty != id.Value)
            {
                var profile = profileCore.SearchSingle <ProfileFull>(id.Value, null, null, true);
                if (null != profile)
                {
                    if (!string.IsNullOrWhiteSpace(profile.FacebookAccessToken))
                    {
                        var fbCore = new FacebookCore();
                        if (string.IsNullOrWhiteSpace(profile.Location))
                        {
                            profile.Location = fbCore.Location(profile.FacebookAccessToken);

                            if (!string.IsNullOrWhiteSpace(profile.Location))
                            {
                                profileCore.Save(profile);
                            }
                        }

                        var emails = fbCore.ImportFriends(profile);
                        foreach (var email in emails)
                        {
                            emailCore.FriendSignedUp(email);
                        }
                    }
                }
            }

            return(View(this.adminCore.Profiles(count)));
        }
コード例 #2
0
        public override void Execute()
        {
            var facebook    = new FacebookCore();
            var profileCore = new ProfileCore();
            var emailCore   = new EmailCore();

            var profiles = profileCore.Search(null, null, null, true, short.MaxValue, int.MaxValue);

            foreach (var profile in profiles)
            {
                try
                {
                    var user = profileCore.SearchSingle <ProfileFull>(profile.Identifier, profile.Key, null, true);
                    if (!string.IsNullOrWhiteSpace(user.FacebookAccessToken) && Guid.Empty != user.Identifier)
                    {
                        var emails = facebook.ImportFriends(user);
                        foreach (var email in emails)
                        {
                            emailCore.NewFriend(email);
                        }
                    }

                    Thread.Sleep(500);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Profile Directory
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Unique(Guid?id, string key = null)
        {
            if (!id.HasValue && string.IsNullOrWhiteSpace(key))
            {
                return(RedirectToAction("Index"));
            }

            var callerId = User.IdentifierSafe();

            var profile = new ProfileMaster()
            {
                Display = profileCore.SearchSingle(id, key, callerId),
            };

            if (null != profile.Display)
            {
                profile.Display.Badges = badgeCore.Search(profile.Display.Identifier);

                profile.Display.Activities = activityCore.UserSearch(profile.Display.Identifier);

                profile.Display.Items = itemCore.Search(profile.Display.Identifier, null, null, short.MaxValue, callerId);

                profile.ItemRequests = itemRequestCore.Search(profile.Display.Identifier, callerId);

                profile.Lent = from s in this.borrowCore.Lent(profile.Display.Identifier)
                               where s.Status == BorrowStatus.Returned
                               select s;
                profile.Borrowed = from s in this.borrowCore.Borrowed(profile.Display.Identifier)
                                   where s.Status == BorrowStatus.Returned
                                   select s;

                return(View(profile));
            }
            else if (!string.IsNullOrWhiteSpace(key))
            {
                return(Redirect(ProfileCore.SearchUrl(key, "unknown_key")));
            }
            else
            {
                return(RedirectToAction("index"));
            }
        }
コード例 #4
0
        //
        // GET: /item
        public ActionResult Index(Guid?user = null, string s = null, bool friends = false)
        {
            var callerId = User.IdentifierSafe();

            if (callerId.HasValue && user.HasValue && user.Value == callerId.Value)
            {
                return(RedirectToAction("inventory", "dashboard"));
            }

            var results = new SearchResults <Item>()
            {
                Manifest          = itemCore.Search(user, s, null, 100, callerId, false, friends),
                SearchDisplayText = s,
            };

            if (user.HasValue && Guid.Empty != user.Value)
            {
                results.User = profileCore.SearchSingle(user, null, callerId);
            }

            if (!string.IsNullOrWhiteSpace(s))
            {
                switch (s)
                {
                case "share":
                    results.SearchDisplayText = "Lend";
                    break;

                case "free":
                    results.SearchDisplayText = "Give away";
                    break;

                case "rent":
                    results.SearchDisplayText = "Rent";
                    break;

                case "trade":
                    results.SearchDisplayText = "Trade";
                    break;
                }
            }

            return(View(results));
        }
コード例 #5
0
ファイル: ShareController.cs プロジェクト: jefking/Borentra
        //
        // GET: /Share/
        public ActionResult Index(Guid?user = null, string s = null, bool friends = false)
        {
            var callerId = User.IdentifierSafe();

            if (callerId.HasValue && user.HasValue && user.Value == callerId.Value)
            {
                return(RedirectToAction("inventory", "dashboard"));
            }

            var results = new SearchResults <Item>()
            {
                SearchDisplayText = "Lend",
                Manifest          = itemCore.Search(user, OfferType.Share, s, 100, callerId, friends),
            };

            if (user.HasValue && Guid.Empty != user.Value)
            {
                results.User = profileCore.SearchSingle(user, null, callerId);
            }

            return(View("~/Views/Item/Index.cshtml", results));
        }
コード例 #6
0
        public Profile My()
        {
            var userId = User.Identifier();

            return(profileCore.SearchSingle(userId, null, userId));
        }
コード例 #7
0
        // GET:/Dashboard
        public ActionResult Index()
        {
            var userId = User.Identifier();

            this.GetCookie(userId);

            var dashboard = profileCore.Load <MyProfile>(userId);
            var profile   = profileCore.SearchSingle <MyProfile>(userId, null, userId);

            profile.Badges = badgeCore.Search(userId);

            if (null != profile)
            {
                profile.Items = itemCore.Search(userId, null, null, null, userId);

                var shares = this.borrowCore.Lent(userId);

                profile.PendingRequests = from br in shares
                                          where br.Status == BorrowStatus.Pending
                                          select br;

                profile.Lent = from br in shares
                               where br.Status == BorrowStatus.Accepted
                               select br;

                shares = this.borrowCore.Borrowed(userId);

                profile.BorrowRequests = from br in shares
                                         where br.Status == BorrowStatus.Pending
                                         select br;

                profile.Borrowed = from br in shares
                                   where br.Status == BorrowStatus.Accepted
                                   select br;

                profile.PendingTradeRequests = this.tradeCore.SearchItemTrade(userId);
                profile.TradeRequests        = this.tradeCore.SearchItemTrade(null, userId);

                this.LoadItems(profile.PendingRequests, true);
                this.LoadItems(profile.BorrowRequests);
                this.LoadItems(profile.Lent, true);
                this.LoadItems(profile.Borrowed);

                profile.FreeAsk       = this.LoadItems(freeCore.Search(userId), true) as IEnumerable <ItemFree>;
                profile.FreeRequested = this.LoadItems(freeCore.Search(null, userId)) as IEnumerable <ItemFree>;

                var fulfillments = from f in this.itemRequestCore.SearchFulfill(userId)
                                   where f.Status == RequestStatus.Pending
                                   select f;

                profile.FulfillMine = from f in fulfillments
                                      where f.IsMine
                                      select f;

                profile.FulfillOthers = from f in fulfillments
                                        where !f.IsMine
                                        select f;

                var rent = from r in this.rentCore.Rented(userId)
                           where r.Status != RentalStatus.Rejected &&
                           r.Status != RentalStatus.Returned
                           select r;
                rent = this.LoadItems(rent, true) as IEnumerable <ItemRental>;

                profile.RentAsks = from r in rent
                                   where r.Status == RentalStatus.Pending
                                   select r;

                profile.Renting = from r in rent
                                  where r.Status == RentalStatus.Accepted
                                  select r;

                rent = from r in this.rentCore.Requested(userId)
                       where r.Status != RentalStatus.Rejected &&
                       r.Status != RentalStatus.Returned
                       select r;
                rent = this.LoadItems(rent) as IEnumerable <ItemRental>;

                profile.RentRequests = from r in rent
                                       where r.Status == RentalStatus.Pending
                                       select r;

                profile.Rented = from r in rent
                                 where r.Status == RentalStatus.Accepted
                                 select r;

                dashboard.Info = profile;
            }

            return(View(dashboard));
        }