public ActionResult PublicCloset(string userName) { if (!IsPublicCloset(userName)) { throw new NotPublicClosetException(); } int?userId = GetUserId(userName); if (IsUserCloset(userId)) { return(RedirectToAction("Index")); } OutfitSearch search = new OutfitSearch(); search.SortBy = "1"; search.Search = SEARCH_TEXT; search.Page = "1"; search.Season = SeasonHelper.CurrentSeasonId; search.SeasonName = SeasonHelper.CurrentSeason.ToString(); search.PageSize = "25"; OutfitView ov = BuildOutfitView(search, userId); ov.Search.Public = true; return(View("Index", ov)); }
public void ClickListener() { if (purchased) { PreviewOutfit(); return; } if (lastClickedView == this) { SetPriceLabel(); RequestPurchasing(); lastClickedView = null; } else { if (lastClickedView != null) { lastClickedView.SetPriceLabel(); } PreviewOutfit(); SetPurchaseLabel(); lastClickedView = this; } }
public JsonResult GetResults(OutfitSearch outfitSearch) { OutfitView ov = BuildOutfitView(outfitSearch, this.UserId); if (ov.Outfits.Count == 0) { outfitSearch.Page = "1"; ov = BuildOutfitView(outfitSearch, this.UserId); } return(Json(new OutfitViewLight(ov))); }
public JsonResult GetResultPublicCloset(OutfitSearch outfitSearch) { if (!IsPublicCloset(outfitSearch.Username)) { throw new NotPublicClosetException(); } int? userId = GetUserId(outfitSearch.Username); OutfitView ov = BuildOutfitView(outfitSearch, userId.Value); ov.Search.Public = true; return(Json(new OutfitViewLight(ov))); }
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); }