Exemplo n.º 1
0
        private void LoadFriendData(int?status)
        {
            if (status == null)
            {
                status = 0;
            }

            dataView.List = true;
            RegisteredUser ru = registeredUserRepository.Get(this.UserId);

            dataView.Friends           = friendRepository.Search(this.ProxyLoggedUser, string.Empty, (FriendStatus)status, 0);
            dataView.NewFriendsRequest = ru.FriendsThatInvitedMe.Count;
            dataView.UserMail          = Membership.GetUser().Email;
            dataView.NewFriend         = new NewFriendView();

            ViewData["GMailAuthUrl"] = new GoogleProvider().GetAuthorizationURL();
            ViewData["LiveAuthUrl"]  = new LiveProvider().GetAuthorizationURL();
            ViewData["YahooAuthUrl"] = "N/D";

            if (Session["NewFriendsAdded"] != null)
            {
                TempData["NewFriendsAdded"] = Session["NewFriendsAdded"];
                Session["NewFriendsAdded"]  = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Actualiza los UserFlavors del usuario por los nuevos seleccionados.
        /// </summary>
        /// <param name="Flavor1Weight">Peso del primer Fashion Flavor seleccionado.</param>
        /// <param name="Flavor2Weight">Peso del segudno Fashion Falvor determinado.</param>
        /// <param name="values">Coleccion de objetos del formulario</param>
        /// <returns>Actualiza los flavors seleccionados y redirecciona a la Home.</returns>
        public ActionResult UpdateUserFlavors(string Flavor1Weight, string Flavor2Weight, string submit)
        {
            bool previous = (submit != null && submit.ToLower() == "previous");

            if (previous)
            {
                return(RedirectToAction("Index", "FlavorSelect"));
            }

            IList <FashionFlavor> flavors     = ClosetState.Flavors;
            IList <UserFlavor>    userFlavors = new List <UserFlavor>();

            if (flavors != null)
            {
                if (!string.IsNullOrEmpty(Flavor1Weight))
                {
                    userFlavors.Add(new UserFlavor(flavors[0], Convert.ToDecimal(Flavor1Weight)));
                }
                if (!string.IsNullOrEmpty(Flavor2Weight))
                {
                    userFlavors.Add(new UserFlavor(flavors[1], Convert.ToDecimal(Flavor2Weight)));
                }
            }

            RegisteredUser user = registeredUserRepository.Get(this.UserId);

            List <int> flavorsIds    = new List <int>();
            List <int> myGarmentsIds = new List <int>();

            foreach (FashionFlavor ff in flavors)
            {
                flavorsIds.Add(ff.Id);
            }

            IList <ClosetGarment> closetGarments = closetRepository.GetGarmentsForUser(user);

            foreach (ClosetGarment closetGarment in closetGarments)
            {
                myGarmentsIds.Add(closetGarment.Garment.Id);
            }

            if (!new OutfitEngineServiceClient().HasValidCombinations(myGarmentsIds, flavorsIds))
            {
                return(RedirectToAction("FlavorChangeResult", "FlavorSelect", new { flavorsChanged = false }));
            }

            user.SetFlavors(userFlavors);

            //Update UserFlavors
            registeredUserRepository.DbContext.BeginTransaction();
            registeredUserRepository.SaveOrUpdate(user);
            registeredUserRepository.DbContext.CommitTransaction();

            new OutfitEngineServiceClient().CreateOutfits(user.Closet.Id);
            UserDataHelper.LoadFromDatabase();

            return(RedirectToAction("FlavorChangeResult", "FlavorSelect", new { flavorsChanged = true }));
        }
Exemplo n.º 3
0
        public IList <ClosetOutfitView> GetTopRatedOutfits(int userId)
        {
            closetOutfitRepository   = new ClosetOutfitRepository();
            registeredUserRepository = new RegisteredUserRepository();
            RegisteredUser user = registeredUserRepository.Get(userId);
            ICriteria      crit = Session.CreateCriteria(typeof(ClosetOutfitView));

            crit.Add(Expression.Eq("UserId", userId));
            crit.AddOrder(new Order("AverageFriendRating", false));
            crit.AddOrder(new Order("AverageUserRating", false));
            crit.AddOrder(new Order("EditorRating", false));
            crit.SetMaxResults(2);

            IList <ClosetOutfitView> result = crit.List <ClosetOutfitView>();

            foreach (ClosetOutfitView closetOutfitView in result)
            {
                closetOutfitView.Disabled = true;
            }
            return(GetComponents(result, user.Closet));
        }
Exemplo n.º 4
0
        public RedirectToRouteResult GoToMyGarments(string myGarmentsItems, string myWishListItems)
        {
            string[] myGarmentsArray = myGarmentsItems.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            string[] myWishListArray = myWishListItems.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            IList <Garment> myGarments        = new List <Garment>();
            List <int>      myGarmentsIds     = new List <int>();
            IList <Garment> myWishGarments    = new List <Garment>();
            List <int>      myWishGarmentsIds = new List <int>();

            if (myGarmentsArray.Length > 0)
            {
                foreach (string garment in myGarmentsArray)
                {
                    if (!string.IsNullOrEmpty(garment) && StringHelper.IsNumber(garment))
                    {
                        myGarmentsIds.Add(Convert.ToInt32(garment));
                    }
                }
            }
            if (myWishListArray.Length > 0)
            {
                foreach (string garment in myWishListArray)
                {
                    if (!string.IsNullOrEmpty(garment) && StringHelper.IsNumber(garment))
                    {
                        myWishGarmentsIds.Add(Convert.ToInt32(garment));
                    }
                }
            }

            garmentRepository.DbContext.BeginTransaction();
            myGarments     = garmentRepository.GetByIds(myGarmentsIds);
            myWishGarments = garmentRepository.GetByIds(myWishGarmentsIds);
            List <int>     newGarmentsIds = new List <int>();
            RegisteredUser user           = registeredUserRepository.Get(this.UserId);

            if (myGarments.Count > 0)
            {
                foreach (Garment garment in myGarments)
                {
                    if (!user.Closet.HasGarment(garment))
                    {
                        user.Closet.AddGarment(garment);
                        newGarmentsIds.Add(garment.Id);
                    }
                }
                registeredUserRepository.SaveOrUpdate(user);
            }

            if (myWishGarments.Count > 0)
            {
                WishList wl = wishListRepository.GetForUser(this.ProxyLoggedUser);
                if (wl == null)
                {
                    wl      = new WishList();
                    wl.User = this.ProxyLoggedUser;
                }
                foreach (Garment garment in myWishGarments)
                {
                    wl.AddGarment(garment);
                }
                wishListRepository.SaveOrUpdate(wl);
            }

            garmentRepository.DbContext.CommitTransaction();

            if (newGarmentsIds.Count > 0)
            {
                // Update the closet combinations
                new FashionAde.Utils.OutfitEngineService.OutfitEngineServiceClient().AddOutfits(user.Closet.Id, newGarmentsIds);
            }

            return(RedirectToAction("Index", "MyGarments"));
        }
Exemplo n.º 5
0
        private IList <ClosetOutfitView> Search(out int totalCount, string SortBy, string Search, string Page, string Season, int UserId)
        {
            RegisteredUser user = registeredUserRepository.Get(UserId);

            return(closetOutfitViewRepository.Search(out totalCount, 10, Convert.ToInt32(Page), Convert.ToInt32(Season), UserId, Search, SortBy, user.Closet));
        }
Exemplo n.º 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));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Get RegisteredUser Information
 /// </summary>
 /// <param name="facebookId">facebookId</param>
 /// <returns>RegisteredUser</returns>
 public RegisteredUser GetRegisteredUser(string facebookId)
 {
     return(_registeredUserRepository.Get(facebookId));
 }