Example #1
0
        public ActionResult Search(Selection selection)
        {
            List <EventType>   selectedET  = (List <EventType>)Session["EventTypeSelected"];
            List <jsonGarment> finalResult = new List <jsonGarment>();

            List <Garment> result = garmentRepository.GetBySelection(silouhetteRepository.Get(selection.SilouhetteId), new Fabric(selection.FabricId), new Pattern(selection.PatternId), selectedET) as List <Garment>;

            if (result != null)
            {
                foreach (Garment garment in result)
                {
                    finalResult.Add(new jsonGarment(garment));
                }
            }

            return(Json(finalResult));
        }
Example #2
0
        public ActionResult Search(Selection selection)
        {
            IList <EventType>     selectedET;
            IList <ClosetGarment> closetGarments = new List <ClosetGarment>();
            IList <WishGarment>   wishGarments   = new List <WishGarment>();

            MembershipUser mu = Membership.GetUser();

            if (mu == null)
            {
                selectedET = eventTypeRepository.GetByIds((from e in ClosetState.EventTypes select e.Id).ToList <int>());
            }
            else
            {
                WishList wl = wishListRepository.GetForUser(this.ProxyLoggedUser);
                if (wl != null)
                {
                    wishGarments = wishListRepository.GetForUser(this.ProxyLoggedUser).Garments;
                }
                closetGarments = closetRepository.GetGarmentsForUser(this.ProxyLoggedUser);
                selectedET     = registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey)).EventTypes;
            }
            HashSet <jsonGarment> finalResult = new HashSet <jsonGarment>();

            HashSet <MasterGarment> result = new HashSet <MasterGarment>(
                garmentRepository.GetBySelection(silouhetteRepository.Get(selection.SilouhetteId),
                                                 new Fabric(selection.FabricId),
                                                 new Pattern(selection.PatternId),
                                                 selectedET,
                                                 closetGarments,
                                                 wishGarments));

            if (result != null)
            {
                foreach (MasterGarment garment in result)
                {
                    finalResult.Add(new jsonGarment(garment));
                }
            }

            return(Json(finalResult));
        }
Example #3
0
        private ArrayList GetFormatedValues(FormCollection values)
        {
            ArrayList   lst       = new ArrayList();
            UserGarment ug        = new UserGarment();
            int         controlId = int.Parse(((NameValueCollection)(values)).AllKeys[0].Substring(
                                                  ((NameValueCollection)(values)).AllKeys[0].Length - 1, 1));

            foreach (string tag in values)
            {
                if (tag == "x" || tag == "y")
                {
                    continue;
                }

                if (int.Parse(tag.Substring(tag.Length - 1)) != controlId)
                {
                    lst.Add(ug);
                    ug = new UserGarment();
                    controlId++;
                }

                string propName  = tag.Substring(0, tag.Length - 1);
                string propValue = values[tag.ToString()];

                if (propValue == "")
                {
                    continue;
                }

                switch (propName)
                {
                case "Title":
                    Silouhette s = silouhetteRepository.Get(int.Parse(propValue));
                    ug.Title           = s.Category.Description + " " + s.Description;
                    ug.Tags.Silouhette = s;
                    break;

                case "Fabric":
                    ug.Tags.Fabric = fabricRepository.Get(int.Parse(propValue));
                    break;

                case "PrimaryColor":
                    ug.Tags.Colors.Add(colorRepository.Get(int.Parse(propValue)));
                    break;

                case "Pattern":
                    ug.Tags.Pattern = patternRepository.Get(int.Parse(propValue));
                    break;

                case "Season":
                    ug.Tags.Seasons.Add((Season)int.Parse(propValue));
                    break;

                case "EventType":
                    ug.Tags.EventTypes.Add(eventTypeRepository.Get(int.Parse(propValue)));
                    break;

                case "PrivacyStatus":
                    ug.Visibility = (Convert.ToBoolean(propValue)) ? GarmentVisibility.Private : GarmentVisibility.Public;
                    break;
                }
            }

            lst.Add(ug);
            return(lst);
        }
Example #4
0
        private ArrayList GetFormatedValues(FormCollection values)
        {
            ArrayList   lst = new ArrayList();
            UserGarment ug  = new UserGarment();

            if (values.Count == 0)
            {
                return(lst);
            }

            int controlId = int.Parse(((NameValueCollection)(values)).AllKeys[0].Substring(
                                          ((NameValueCollection)(values)).AllKeys[0].Length - 1, 1));

            string titleSilouhette = string.Empty;
            string titleCategory   = string.Empty;
            string titleColor      = string.Empty;
            string titlePattern    = string.Empty;
            string titleFabric     = string.Empty;

            foreach (string tag in values)
            {
                if (tag == "x" || tag == "y")
                {
                    continue;
                }

                if (int.Parse(tag.Substring(tag.Length - 1)) != controlId)
                {
                    ug.Title = string.Format("{0} {1} {2} {3} {4}", titleSilouhette, titleColor, titlePattern, titleCategory, titleFabric);
                    lst.Add(ug);
                    ug = new UserGarment();
                    titleSilouhette = string.Empty;
                    titleCategory   = string.Empty;
                    titleColor      = string.Empty;
                    titlePattern    = string.Empty;
                    titleFabric     = string.Empty;
                    controlId++;
                }

                string propName  = tag.Substring(0, tag.Length - 1);
                string propValue = values[tag.ToString()];

                if (propValue == "")
                {
                    continue;
                }

                switch (propName)
                {
                case "Title":
                    Silouhette s = silouhetteRepository.Get(int.Parse(propValue));
                    titleSilouhette    = s.Description;
                    titleCategory      = s.Category.Description;
                    ug.Tags.Silouhette = s;
                    break;

                case "Fabric":
                    Fabric f = fabricRepository.Get(int.Parse(propValue));
                    ug.Tags.Fabric = f;
                    titleFabric    = f.Description;
                    break;

                case "PrimaryColor":
                    FashionAde.Core.Clothing.Color col = colorRepository.Get(int.Parse(propValue));
                    ug.Tags.Colors.Add(col);
                    ug.Tags.DefaultColor = col;
                    titleColor           = col.Description;
                    break;

                case "Pattern":
                    Pattern p = patternRepository.Get(int.Parse(propValue));
                    ug.Tags.Pattern = p;
                    titlePattern    = p.Description;
                    break;

                case "Season":
                    ug.Tags.Seasons.Add((Season)int.Parse(propValue));
                    break;

                case "EventType":
                    ug.Tags.EventTypes.Add(eventTypeRepository.Get(int.Parse(propValue)));
                    break;

                case "PrivacyStatus":
                    ug.SetVisibility((Convert.ToBoolean(propValue)) ? GarmentVisibility.Private : GarmentVisibility.Public);
                    break;
                }
            }
            ug.Title = string.Format("{0} {1} {2} {3} {4}", titleSilouhette, titleColor, titlePattern, titleCategory, titleFabric);

            if (ug.Title != "    ")
            {
                lst.Add(ug);
            }
            return(lst);
        }