コード例 #1
0
        public ClosetOutfitView GetByClosetOutfitId(int closetOutfitId)
        {
            ClosetOutfit closetOutfit = Get(closetOutfitId);

            if (closetOutfit == null)
            {
                return(null);
            }
            ICriteria closet;
            ICriteria crit = GetCrit(out closet);

            crit.Add(Expression.Eq("co.Id", closetOutfitId));
            crit.SetResultTransformer(new NHibernate.Transform.AliasToBeanConstructorResultTransformer(typeof(ClosetOutfitView).GetConstructors()[0]));

            ClosetOutfitView tempOV = crit.UniqueResult <ClosetOutfitView>();

            if (tempOV == null)
            {
                return(null);
            }

            List <ClosetOutfitView> result = new List <ClosetOutfitView>();

            result.Add(tempOV);

            ClosetOutfitView view = GetComponents(result, null)[0];

            view.ClosetOutfit = closetOutfit;
            return(view);
        }
コード例 #2
0
 private FriendRatingView LoadViewData(FriendRatingView viewData, ClosetOutfitView closetOutfitView, int invitationId)
 {
     viewData.ClosetOutfit   = closetOutfitView;
     viewData.Updater        = outfitUpdaterRepository.GetRandomOutfitUpdaterFor(closetOutfitView.PreCombination);
     viewData.InvitationId   = invitationId;
     viewData.ClosetOutfitId = closetOutfitView.ClosetOutfitId;
     viewData.UserName       = closetOutfitView.ClosetOutfit.Closet.User.FullName;
     return(viewData);
 }
コード例 #3
0
        public ActionResult Vote(int id)
        {
            ClosetOutfitView cv = closetOutfitRepository.GetByClosetOutfitId(id);

            if (cv == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            FriendRatingView viewData = LoadViewData(new FriendRatingView(), cv, 0);

            return(View(viewData));
        }
コード例 #4
0
        public ActionResult VoteFromInvitation(Guid id)
        {
            FriendRatingInvitation invitation = friendRatingInvitationRepository.GetByKey(id.ToString());

#if !DEBUG
            if (!IsValidInvitation(invitation))
            {
                return(RedirectToAction("Index", "Home"));
            }
#endif

            ClosetOutfitView cv = closetOutfitRepository.GetByClosetOutfitId(invitation.ClosetOutfit.Id);

            FriendRatingView viewData = LoadViewData(new FriendRatingView(), cv, 0);
            return(View("Vote", viewData));
        }
コード例 #5
0
        private OutfitView BuildOutfitView(OutfitSearch outfitSearch, int?userId)
        {
            int    totalCount;
            string originalSearch = outfitSearch.Search;

            bool           showAsPublicCloset = ShowAsPublicCloset(userId);
            RegisteredUser user = (showAsPublicCloset)
                                ? registeredUserRepository.Get(userId.Value)
                                : registeredUserRepository.Get(this.ProxyLoggedUser.Id);

            BasicUser currentUser = null;

            if (User.Identity.IsAuthenticated)
            {
                currentUser = registeredUserRepository.Get(this.UserId);
            }

            if (!AccessClosetService.CanViewCloset(currentUser, user.Closet))
            {
                throw new NotPublicClosetException();
            }

            if (originalSearch == SEARCH_TEXT)
            {
                outfitSearch.Search = string.Empty;
            }

            GetOutfitsInfo(showAsPublicCloset);

            IList <ClosetOutfitView> lstResults = new List <ClosetOutfitView>();

            lstResults = this.Search(out totalCount, outfitSearch, user);
            string userName = Membership.GetUser(user.MembershipUserId).UserName;

            OutfitView ov = new OutfitView();

            ov.Search = new OutfitSearch();
            if (showAsPublicCloset)
            {
                ov.StyleAlerts = contentService.GetRandomStyleAlerts();
                foreach (ClosetOutfitView cov in lstResults)
                {
                    cov.Disabled          = true;
                    cov.ShowAddToMyCloset = true;
                    cov.SendToFriends     = false;
                }
                userName += "'s Outfits";
            }
            else
            {
                ov.StyleAlerts = contentService.GetRandomStyleAlerts((IList <FashionFlavor>)ViewData["fashionFlavors"]);
            }

            ov.FilterText                = originalSearch;
            ov.Closet                    = user.Closet;
            ov.UserName                  = userName;
            ov.Outfits                   = lstResults;
            ov.TotalOutfits              = totalCount;
            ov.Season                    = outfitSearch.Season;
            ov.PrivacyLevel              = user.Closet.PrivacyLevel.ToString();
            ov.CurrentPage               = outfitSearch.Page;
            ov.ShowAsPublicCloset        = showAsPublicCloset;
            ov.Search.ShowAsPublicCloset = showAsPublicCloset;
            ov.Search.Patterns           = patterRepository.GetAll() as List <Pattern>;
            ov.Search.Categories         = new List <SelectListItem>();
            SelectListItem noCategory = new SelectListItem();

            noCategory.Text  = NOCATEGORY;
            noCategory.Value = "0";
            ov.Search.Categories.Add(noCategory);
            ov.Search.Categories.AddRange(GetCategorySelectListItemList(categoryRepository.GetAll()));
            ov.Search.Trends = new List <SelectListItem>();
            SelectListItem noTrend = new SelectListItem();

            noTrend.Text  = NOTREND;
            noTrend.Value = "0";
            ov.Search.Trends.Add(noTrend);
            ov.Search.Trends.AddRange(GetTrendSelectListItemList(trendRepository.GetCurrentTrends()));
            ov.Search.Colors     = colorRepository.GetAll() as List <Color>;
            ov.Search.Page       = outfitSearch.Page;
            ov.Search.Season     = outfitSearch.Season;
            ov.Search.SeasonName = outfitSearch.SeasonName;
            ov.Search.EventTypes = new List <SelectListItem>();
            foreach (EventType eventType in user.EventTypes)
            {
                SelectListItem item = new SelectListItem();
                item.Text  = eventType.Description;
                item.Value = eventType.Id.ToString();
                ov.Search.EventTypes.Add(item);
            }
            ov.Search.Flavors = new List <SelectListItem>();
            foreach (UserFlavor userFlavor in user.UserFlavors)
            {
                SelectListItem item = new SelectListItem();
                item.Text  = userFlavor.Flavor.Name;
                item.Value = userFlavor.Flavor.Id.ToString();
                ov.Search.Flavors.Add(item);
            }
            ov.Search.SavedFilters = savedFilterRepository.GetAllFor(UserId) as List <SavedFilter>;

            if (user.Closet.FavoriteOutfit != null)
            {
                ClosetOutfitView couv = closetOutfitRepository.GetByClosetOutfitId(ov.FavoriteOutfitId);
                if (couv != null)
                {
                    ov.FavoriteOutfitId = user.Closet.FavoriteOutfit.Id;
                    ov.FavoriteOutfit   = couv.ShortEventTypes + ov.FavoriteOutfitId;
                }
            }
            else
            {
                ov.FavoriteOutfit = "None Selected";
            }


            ViewData["procesingCloset"] = user.Closet.CreationStatus == ClosetGarmentStatus.Pending && IsSameUser(user.Id);
            ViewData["userId"]          = user.Id;
            ViewData["closetUserId"]    = user.MembershipUserId;
            ov.Pager          = PagingHelper.Paging(totalCount, Convert.ToInt32(outfitSearch.Page), Convert.ToInt32(outfitSearch.PageSize), 4);
            ViewData["Pages"] = ov.Pager;
            //TODO: Hacer modificable este seteo
            ViewData["StyleAlertsStep"] = 5;

            foreach (ClosetOutfitView cov in lstResults)
            {
                if (cov.OutfitUpdater == null)
                {
                    cov.OutfitUpdater = outfitUpdaterRepository.Get(ConfigurationManager.AppSettings["DefaultOU"]);
                }

                //We also need to be able to obtain the number of impressiones (views) of an outfit updaters.
                TrackingHelper.SaveOutfitUpdaterInfo(cov.OutfitUpdater.Id.ToString(), cov.ClosetOutfitId.ToString());
            }
            ov.Search.Public = false;

            return(ov);
        }
コード例 #6
0
        public ActionResult OutfitResume(int outfitId)
        {
            ClosetOutfitView closetOutfitView = closetOutfitRepository.GetByClosetOutfitId(outfitId);
            OutfitResume     or = new OutfitResume();

            or.OutfitView = closetOutfitView;
            if (UserId == closetOutfitView.ClosetOutfit.Closet.User.Id)
            {
                or.GetRatings();
            }

            if (or.OutfitView == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            BasicUser user = null;

            if (User.Identity.IsAuthenticated)
            {
                user = registeredUserRepository.Get(this.UserId);
            }

            if (!AccessClosetService.CanViewClosetOutfit(user, or.OutfitView.ClosetOutfit))
            {
                throw new NotPublicClosetException();
            }

            or.OutfitView.Disabled      = (this.ProxyCloset == null || or.OutfitView.ClosetOutfit.Closet.Id != this.ProxyCloset.Id);
            or.OutfitView.SendToFriends = !or.OutfitView.Disabled;

            or.UserClosetUrl = (or.OutfitView.Disabled)
                                        ? Url.Action("PublicCloset", "MyOutfits", new { username = or.OutfitView.ClosetOutfit.Closet.User.UserName })
                                        : Url.Action("Index", "MyOutfits");

            bool isFavoriteOutfit = (closetOutfitView.ClosetOutfit.Closet.FavoriteOutfit != null &&
                                     closetOutfitView.ClosetOutfit.Closet.FavoriteOutfit.Id == outfitId)
                                        ? true
                                        : false;

            or.OutfitView.ClosetOutfit.IsFavouriteOutfit = isFavoriteOutfit;

            if (user != null && !IsSameUser(closetOutfitView.ClosetOutfit.Closet.User.Id))
            {
                or.OutfitView.Disabled          = true;
                or.OutfitView.ShowAddToMyCloset = !IsSameUser(closetOutfitView.ClosetOutfit.Closet.User.Id);
                or.OutfitView.SendToFriends     = IsSameUser(closetOutfitView.ClosetOutfit.Closet.User.Id);
            }

            if (or.OutfitView.OutfitUpdater == null)
            {
                or.OutfitView.OutfitUpdater = outfitUpdaterRepository.Get(ConfigurationManager.AppSettings["DefaultOU"]);
            }
            //We need to be able to track the number of impressiones (views) of an outfit updaters.
            if (or.OutfitView.OutfitUpdater != null)
            {
                TrackingHelper.SaveOutfitUpdaterInfo(or.OutfitView.OutfitUpdater.Id.ToString(),
                                                     or.OutfitView.ClosetOutfitId.ToString());
            }

            return(View(or));
        }
コード例 #7
0
        public ActionResult Vote(FriendRatingView view)
        {
            if (ModelState.IsValid)
            {
                FriendRatingInvitation invitation;

                // Check if this is a new invitation from an anonymous user
                if (view.InvitationId == 0)
                {
                    invitation = new FriendRatingInvitation();
                    invitation.ClosetOutfit = closetOutfitRepository.Get(view.ClosetOutfitId);
                    invitation.User         = invitation.ClosetOutfit.Closet.User;

                    invitation.FriendEmail      = "Generated by FaceBook";
                    invitation.KeyCode          = string.Empty;
                    invitation.InvitationSentOn = DateTime.Today;
                }
                else
                {
                    invitation = friendRatingInvitationRepository.Get(view.InvitationId);
                    if (!IsValidInvitation(invitation))
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }

                invitation.Rate         = view.FriendRating;
                invitation.FriendRateOn = DateTime.Now;
                invitation.Message      = "";
                if (!string.IsNullOrEmpty(view.Comment))
                {
                    //invitation.Message = HttpUtility.HtmlEncode(view.Comment);
                    invitation.Message = view.Comment;
                }

                ClosetOutfit closetOutfit = closetOutfitRepository.Get(view.ClosetOutfitId);
                closetOutfit.Rating.Rate(view.FriendRating, invitation);
                closetOutfitRepository.SaveOrUpdate(closetOutfit);

                using (SearchEngineService ses = SearchEngineService.GetByCloset(ClosetId))
                    ses.AddEntry(closetOutfit.ToSearchEngineEntry());

                friendRatingInvitationRepository.SaveOrUpdate(invitation);

                ConfirmRatingData data = new ConfirmRatingData
                {
                    Components  = closetOutfit.Components,
                    Comments    = HttpUtility.HtmlEncode(view.Comment),
                    GarmentsUri = Resources.GetGarmentLargePath(),
                    RatingImg   = Resources.GetRatingLargePath() + view.FriendRating + ".jpg",
                    RatingText  = Resources.GetRatingText(view.FriendRating)
                };

                messageSenderService.SendWithTemplate("confirmrating", invitation.User, data, invitation.User.EmailAddress);
                return(RedirectToAction("Thanks"));
            }

            ClosetOutfitView cv = closetOutfitRepository.GetByClosetOutfitId(view.ClosetOutfitId);

            view = LoadViewData(view, cv, 0);

            return(View(view));
        }