public ActionResult GetSilouhette(Selection selection) { SilouhetteSelection silouhetteSelection = new SilouhetteSelection(); try { Silouhette silouhette = silouhetteRepository.Get(selection.SilouhetteId); IList <EventType> selectedET; MembershipUser mu = Membership.GetUser(); if (mu == null) { selectedET = eventTypeRepository.GetByIds((from e in ClosetState.EventTypes select e.Id).ToList <int>()); } else { selectedET = registeredUserRepository.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey)).EventTypes; } HashSet <Fabric> fabrics = new HashSet <Fabric>(fabricRepository.GetForSilouhette(silouhette, selectedET)); silouhetteSelection.Patterns = new HashSet <Pattern>(silouhette.AvailablePatterns); silouhetteSelection.Fabrics = fabrics; silouhetteSelection.Success = true; ViewData.Model = selection.SilouhetteId; } catch (Exception) { silouhetteSelection.Success = false; } return(Json(silouhetteSelection)); }
public IList <Garment> GetBySilouhette(Silouhette silouhette) { ICriteria crit = Session.CreateCriteria(typeof(Garment)).CreateCriteria("Tags"); ICriteria silouhettes = crit.CreateCriteria("Silouhette"); silouhettes.Add(Expression.Eq("Id", silouhette.Id)); return(crit.List <Garment>()); }
public IList <MasterGarment> GetBySelection(Silouhette silouhette, Fabric fabric, Pattern pattern, IList <EventType> selectedET, IList <ClosetGarment> closetGarments, IList <WishGarment> wishGarments) { fabricRepository = new FabricRepository(); if (fabric == null || fabric.Id == 0) { fabric = fabricRepository.GetForSilouhette(silouhette, selectedET)[0]; } if (pattern == null || pattern.Id == 0) { pattern = silouhette.AvailablePatterns[0]; } List <int> eventTypesIds = new List <int>(); foreach (EventType eventType in selectedET) { eventTypesIds.Add(eventType.Id); } ICriteria crit = Session.CreateCriteria(typeof(MasterGarment)); ICriteria tags = crit.CreateCriteria("Tags"); ICriteria silouhettes = tags.CreateCriteria("Silouhette"); silouhettes.Add(Expression.Eq("Id", silouhette.Id)); ICriteria fabrics = tags.CreateCriteria("Fabric"); fabrics.Add(Expression.Eq("Id", fabric.Id)); ICriteria patterns = tags.CreateCriteria("Pattern"); patterns.Add(Expression.Eq("Id", pattern.Id)); int sum = 0; foreach (EventType et in selectedET) { sum += et.BinaryNumber; } crit.Add(Restrictions.Gt(Projections.SqlProjection("(this_.EventCode & " + sum + ") as bitWiseResult2", new[] { "bitWiseResult" }, new IType[] { NHibernateUtil.Int32 }), 0)); foreach (ClosetGarment closetGarment in closetGarments) { crit.Add(Expression.Not(Expression.Eq("Id", closetGarment.Garment.Id))); } foreach (WishGarment wishGarment in wishGarments) { crit.Add(Expression.Not(Expression.Eq("Id", wishGarment.Garment.Id))); } crit.Add(Expression.Not(Expression.Eq("Id", 0))); crit.SetCacheable(true); crit.SetCacheRegion("Static"); return(crit.List <MasterGarment>()); }
private PreGarment CreatePreGarment(Silouhette s, ColorFamily cf, PatternType pt) { PreGarment g = new PreGarment(); g.PreSilouhette = s.PreSilouhette; g.ColorFamily = cf; g.PatternType = pt; return(g); }
public ActionResult GetSilouhette(Selection selection) { Silouhette silouhette = silouhetteRepository.Get(selection.SilouhetteId); List <EventType> selectedET = (List <EventType>)Session["EventTypeSelected"]; IList <Fabric> fabrics = fabricRepository.GetForSilouhette(silouhette, selectedET); SilouhetteSelection silouhetteSelection = new SilouhetteSelection(silouhette.AvailablePatterns, fabrics); silouhetteSelection.FabricId = fabricRepository.GetForSilouhette(silouhette, selectedET)[0].Id; return(Json(silouhetteSelection)); }
public OutfitUpdater(int id, string description, string name, double price, string buyurl, string imageurl, string partnerCode, string partnerName, int silouhetteid) { this.Id = id; this.description = description; this.name = name; this.price = (decimal?)price; this.buyUrl = buyurl; this.imageUrl = imageurl; this.partner = new Partner(partnerCode, partnerName); this.silouhette = new Silouhette(silouhetteid); }
/// <summary> /// Determines if a garment is an accessory /// </summary> /// <param name="garment">Garment</param> /// <returns>True if it is an accessory</returns> public static bool IsAccessory(Silouhette silouhette) { return(silouhette.Layers.Contains(LayerCode.ACC1) || silouhette.Layers.Contains(LayerCode.ACC2) || silouhette.Layers.Contains(LayerCode.ACC3) || silouhette.Layers.Contains(LayerCode.ACC4) || silouhette.Layers.Contains(LayerCode.ACC5) || silouhette.Layers.Contains(LayerCode.ACC6) || silouhette.Layers.Contains(LayerCode.ACC7) || silouhette.Layers.Contains(LayerCode.ACC8)); }
public IList <Fabric> GetForSilouhette(Silouhette silouhette, IList <EventType> eventTypes) { string eventIds = ""; foreach (EventType eventType in eventTypes) { eventIds += eventType.Id + ","; } eventIds = eventIds.TrimEnd(','); string query = "select distinct temp.fabricid, f.description from silouhettefabricsbyeventtypes temp inner join fabrics f on temp.fabricid = f.fabricid where temp.silouhetteid = " + silouhette.Id + " and temp.eventtypeid in (" + eventIds + ")"; IQuery q = NHibernateSession.Current.CreateSQLQuery(query); q.SetResultTransformer(new NHibernate.Transform.AliasToBeanConstructorResultTransformer(typeof(Fabric).GetConstructors()[2])); return(q.List <Fabric>()); }
public OutfitUpdater(int id, string name, string keywords, string description, string externalId, double price, string buyUrl, string imageUrl, int partnerId, int silouhetteId, int patternId, int colorFamilyId, int status) { this.Id = id; this.name = name; this.description = description; this.keywords = keywords; this.externalId = externalId; if (price > 0) { this.price = Convert.ToDecimal(price); } this.buyUrl = buyUrl; this.imageUrl = imageUrl; this.partner = new Partner(partnerId); this.silouhette = new Silouhette(silouhetteId); this.pattern = new Pattern(patternId); this.colorFamily = new ColorFamily(colorFamilyId); this.status = (OutfitUpdaterStatus)status; }
public IList <OutfitUpdater> GetFor(Silouhette silouhette, ColorFamily colorFamily, int pageNumber, int pageSize, out int totalCount) { ICriteria crit = Session.CreateCriteria(typeof(OutfitUpdater)); crit.Add(Expression.Eq("Season", SeasonHelper.CurrentSeason)); crit.CreateCriteria("Silouhette").Add(Expression.Eq("Id", silouhette.Id)); crit.Add(Expression.Not(Expression.Ge("Status", OutfitUpdaterStatus.Valid))); totalCount = crit.SetProjection(Projections.ProjectionList().Add(Projections.Count("Id"))).UniqueResult <int>(); string sizeandpage = pageSize.ToString(); if (pageNumber > 1) { sizeandpage += ", " + pageSize; } string query = string.Format("SELECT ou.outfitupdaterid, ou.description, ou.name, ou.price, ou.buyurl, ou.imageurl, p.Code, p.Name, ou.silouhetteid FROM outfitupdaters ou inner join partners p ON ou.PartnerId = p.PartnerId inner join silouhettes s ON ou.SilouhetteId = s.SilouhetteId WHERE ou.Status >= {0} and ou.Season = {3} and s.CategoryId = {1} ORDER BY RAND() LIMIT {2};", Convert.ToInt32(OutfitUpdaterStatus.Valid), silouhette.Category.Id, sizeandpage, (int)SeasonHelper.CurrentSeason); IQuery q = Session.CreateSQLQuery(query); q.SetResultTransformer(new NHibernate.Transform.AliasToBeanConstructorResultTransformer(typeof(OutfitUpdater).GetConstructors()[3])); return(q.List <OutfitUpdater>()); }
private Silouhette CreateSilouhette(string description, params LayerCode[] layerCodes) { Silouhette sil = new Silouhette { Description = description }; //foreach (LayerCode lc in layerCodes) // sil.Layers.Add(lc); sil.PreSilouhette = new PreSilouhette { Layer = layerCodes[0], ShapeType = GetRandomShape().Type, StructureType = GetRandomStructure().Type }; if (rnd.Next(0, 5) != 0) // Some could be for all flavors. { sil.FashionFlavors.Add(CreateFashionFlavors()[rnd.Next(0, 8)]); } else { foreach (FashionFlavor flavor in CreateFashionFlavors()) { sil.FashionFlavors.Add(flavor); } } //if (rnd.Next(0, 5) != 0) // Some could be for all seasons. //{ // // Most logically they will be used on two seasons. // if (rnd.Next(0, 2) == 0) // { // sil.Seasons.Add(Season.Summer); // sil.Seasons.Add(Season.Spring); // } // else // { // sil.Seasons.Add(Season.Winter); // sil.Seasons.Add(Season.Fall); // } //} //else //{ foreach (Season season in Enum.GetValues(typeof(Season))) { sil.Seasons.Add(season); } //} //if (rnd.Next(0, 5) != 0) // Some could be for all seasons. //{ // sil.EventTypes.Add(GetRandomEventType()); // sil.EventTypes.Add(GetRandomEventType()); // sil.EventTypes.Add(GetRandomEventType()); //} //else //{ foreach (EventType eventType in CreateEventTypes()) { sil.EventTypes.Add(eventType); } //} return(sil); }
public Garment Find(Category category, Silouhette silouhette, Color color, Pattern n) { throw new NotImplementedException(); }
public OutfitUpdater(int Id, Silouhette s, ColorFamily c, Pattern p) { this.silouhette = s; this.colorFamily = c; this.pattern = p; }
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); }
public static string GetSilouhettePath(Silouhette silouhette) { return(rootPath + "res/Silouhettes/" + silouhette.ImageUri); }
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); }
public static string GetSilouhettePath(Silouhette silouhette) { return(GetRootPath() + "/Silouhettes/" + silouhette.ImageUri); }