public ActionResult GetClosetGarmentDetails(int garmentSelected)
        {
            ClosetGarment garment = closetRepository.GetClosetGarment(garmentSelected);

            if (garment.Details == null)
            {
                return(Json(new
                {
                    PurchasedAt = string.Empty,
                    PurchasedOn = string.Empty,
                    MadeBy = string.Empty,
                    MadeOf = string.Empty,
                    IsTailored = string.Empty,
                    CareConditions = string.Empty,
                    StoreConditions = string.Empty
                }));
            }
            string date = "";

            if (garment.Details.PurchasedOn != null)
            {
                date = Convert.ToDateTime(garment.Details.PurchasedOn).ToShortDateString();
            }
            return(Json(new
            {
                PurchasedAt = garment.Details.PurchasedAt,
                PurchasedOn = date,
                MadeBy = garment.Details.MadeBy,
                MadeOf = garment.Details.MadeOf,
                IsTailored = garment.Details.IsTailored.ToString(),
                CareConditions = garment.Details.CareConditions,
                StoreConditions = garment.Details.StoreConditions
            }));
        }
Ejemplo 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 }));
        }
Ejemplo n.º 3
0
        public ActionResult SaveUserOutfit(UserOutfitSelection userOutfitselection)
        {
            UserOutfit uo = new UserOutfit();

            uo.AddSeason(userOutfitselection.Season);

            MembershipUser mu   = Membership.GetUser();
            RegisteredUser user = registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey));

            uo.User = user;

            for (int i = 0; i < userOutfitselection.ClosetOutfits.Length; i++)
            {
                uo.AddComponent(closetRepository.GetClosetGarment(Convert.ToInt32(userOutfitselection.ClosetOutfits.GetValue(i))).Garment);
            }

            uo.Visibility = userOutfitselection.PrivacyStatus;
            userOutfitRepository.SaveOrUpdate(uo);

            uo.Closet = user.Closet;
            closetOutfitRepository.SaveOrUpdate(uo);

            return(Json(new { Success = true }));
        }