Esempio n. 1
0
        public ActionResult AddNotateToCloset(OutfitNotate outfitNotate)
        {
            ClosetOutfit outfit = closetOutfitRepository.Get(outfitNotate.OutfitSelected);

            if (StringHelper.IsDateTime(outfitNotate.WornDate))
            {
                IFormatProvider formatProvider = new CultureInfo("en-US");
                outfit.Notate(outfitNotate.Location, Convert.ToDateTime(outfitNotate.WornDate, formatProvider));
                if (outfit.Detail == null)
                {
                    outfit.Detail = new MaxOutfitDetail();
                    outfit.Detail.ClosetOutfit = outfit;
                }
                if (outfit.Detail.WornDate < Convert.ToDateTime(outfitNotate.WornDate, formatProvider))
                {
                    outfit.Detail.WornDate = Convert.ToDateTime(outfitNotate.WornDate, formatProvider);
                    outfit.Detail.Location = outfitNotate.Location;
                }
                else
                {
                    outfitNotate.Location = outfit.Detail.Location;
                    outfitNotate.WornDate = outfit.Detail.WornDate.ToString("MM/dd/yyyy");
                }

                closetOutfitRepository.SaveOrUpdate(outfit);

                // Update index on notate...
                using (SearchEngineService ses = SearchEngineService.GetByCloset(ClosetId))
                    ses.AddEntry(outfit.ToSearchEngineEntry());

                return(Json(new { Success = true, outfitNotate.WornDate, outfitNotate.Location }));
            }

            return(Json(new { Success = false }));
        }
Esempio n. 2
0
        public ActionResult SaveUserOutfit(UserOutfitSelection userOutfitselection)
        {
            IList <Garment> garments = new List <Garment>();
            ClosetOutfit    co;

            for (int i = 0; i < userOutfitselection.ClosetOutfits.Length; i++)
            {
                garments.Add(
                    closetRepository.GetClosetGarment(Convert.ToInt32(userOutfitselection.ClosetOutfits.GetValue(i)))
                    .Garment);
            }
            try
            {
                co = outfitCreationService.CreateUserOutfit(this.UserId, garments, userOutfitselection.Season, userOutfitselection.PrivacyStatus);
            }
            catch (NotValidCombinationException)
            {
                return(Json(new { Success = false, Message = "Oops, looks like you have more than one of something in this outfit – please use only one jacket, one pant, etc. to create an outfit." }));
            }
            catch (CombinationAlreadyExistsException)
            {
                return(Json(new { Success = false, Message = "This combination already exists. Try again!" }));
            }

            new OutfitUpdaterServiceClient().MatchOutfitUpdatersForCloset(ClosetId);

            using (SearchEngineService ses = SearchEngineService.GetByCloset(ClosetId))
            {
                ses.AddEntry(co.ToSearchEngineEntry());
            }

            return(Json(new { Success = true }));
        }
Esempio n. 3
0
        public void CanUpdateIndex()
        {
            CreateIndex(1);

            using (SearchEngineService ses = SearchEngineService.GetByCloset(1))
            {
                //int totalEntry = ses.GetTotalIndexedEntryCount();
                //ses.RemovePost(2);
                //Assert.IsTrue(ses.GetTotalIndexedEntryCount() == totalEntry - 1);

                SearchEngineEntry see = new SearchEngineEntry();
                see.EntryId = 2;
                int amountOfClothes = rnd.Next(10) + 1;

                see.Categories   = GetRandom(categories, amountOfClothes / 2);
                see.Colors       = GetRandom(colors, amountOfClothes);
                see.Silouhettes  = GetRandom(silouhettes, amountOfClothes);
                see.EventTypes   = GetRandom(eventTypes);
                see.Fabrics      = GetRandom(fabrics);
                see.Seasons      = GetRandom(seasons);
                see.Tags         = GetRandom(tags);
                see.CreatedByMe  = true;
                see.EditorRating = Convert.ToInt32(GetRandom(rating, 1));
                see.FriendRating = Convert.ToInt32(GetRandom(rating, 1));
                see.MyRating     = 6;
                see.FlavorId     = Convert.ToInt32(GetRandom(flavor, 1));

                ses.AddEntry(see);
                //Assert.IsTrue(ses.GetTotalIndexedEntryCount() == totalEntry);

                SearchParameters sp = new SearchParameters();
                //sp.CreatedByMe = true;
                sp.MyRating = 6;

                SearchEngineResponse ser = ses.Search(sp, 0, 10, "EditorRating", false);
                Assert.IsTrue(ser.TotalCount == 1);
            }
        }
Esempio n. 4
0
        public ActionResult RateOutfit(OutfitRate outfitRate)
        {
            ClosetOutfit closetOutfit = closetOutfitRepository.Get(outfitRate.ClosetOutfitId);

            if (closetOutfit.Rating == null)
            {
                closetOutfit.Rating = new Rating();
            }
            closetOutfit.Rating.Rate(closetOutfit, outfitRate.Rate);

            ActionResult res = Json(new { Success = true });

            if (outfitRate.Rate == 5)
            {
                if (closetOutfit.Closet.FavoriteOutfit != null)
                {
                    closetOutfitRepository.SaveOrUpdate(closetOutfit);
                    res = Json(new { Success = true, ReplaceFavorite = true });
                }
                else
                {
                    res = SetFavorite(outfitRate);
                }
            }

            if (closetOutfit.Closet.FavoriteOutfit != null && closetOutfit.Closet.FavoriteOutfit.Id == closetOutfit.Id)
            {
                res = Json(new { Success = true, RemoveFavorite = true });
            }

            closetOutfitRepository.SaveOrUpdate(closetOutfit);

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

            return(res);
        }
Esempio n. 5
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));
        }