Esempio n. 1
0
        public IEnumerable <Item> Get(Guid?identifier = null, string s = null, string key = null)
        {
            var callerId = User.IdentifierSafe();

            if ((identifier.HasValue && Guid.Empty != identifier.Value) ||
                !string.IsNullOrWhiteSpace(key))
            {
                var list = new List <Item>(1);
                list.Add(itemCore.GetItem(identifier, key, callerId));
                return(list);
            }
            else
            {
                return(itemCore.Search(null, s, null, null, callerId));
            }
        }
Esempio n. 2
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));
        }
Esempio n. 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"));
            }
        }
Esempio n. 4
0
        //
        // 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));
        }
Esempio n. 5
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));
        }