private GarmentsListData GetGarmentsListDataForNewUser() { GarmentsListData gld = new GarmentsListData(); gld.Controller = "GarmentSelector"; gld.Action = "GoToRegistration"; gld.FashionFlavors = fashionFlavorRepository.GetByIds((from f in ClosetState.Flavors select f.Id).ToList <int>()).ToList <FashionFlavor>(); gld.EventTypes = eventTypeRepository.GetByIds((from e in ClosetState.EventTypes select e.Id).ToList <int>()); if (gld.FashionFlavors != null) { gld.Silouhettes = silouhetteRepository.GetByFlavors(gld.FashionFlavors, gld.EventTypes) as List <Silouhette>; if (gld.Silouhettes != null) { gld.Fabrics = fabricRepository.GetForSilouhette(gld.Silouhettes[0], gld.EventTypes); gld.FabricId = gld.Fabrics.FirstOrDefault().Id; gld.SilouhetteId = gld.Silouhettes[0].Id; Pattern solid = patternRepository.GetSolid(); gld.Garments = garmentRepository.GetBySelection(gld.Silouhettes[0], gld.Fabrics.FirstOrDefault(), solid, gld.EventTypes, new List <ClosetGarment>(), gld.MyWishGarments); gld.PatternId = solid.Id; gld.Patterns = gld.Silouhettes[0].AvailablePatterns; if (ClosetState.AddGarments != null) { if (ClosetState.AddGarments.Count > 0) { foreach (int garment in ClosetState.AddGarments) { gld.NewGarmentsIds += garment + ","; } gld.NewGarmentsIds.TrimEnd(','); gld.NewGarments = garmentRepository.GetByIds(ClosetState.AddGarments); } } if (ClosetState.WishGarments != null) { if (ClosetState.WishGarments.Count > 0) { foreach (int garment in ClosetState.WishGarments) { gld.NewWishGarmentsIds += garment + ","; } gld.NewWishGarmentsIds.TrimEnd(','); gld.NewWishGarments = garmentRepository.GetByIds(ClosetState.WishGarments); } } } } return(gld); }
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>()); }
public ViewResult GarmentSelector() { if (IsLogged()) { return(View("Redirect")); } if (Session["FashionFlavorSelected"] == null) { GetDataForIndex(); return(View("Index", fashionFlavorRepository.GetAll())); } List <FashionFlavor> selectedFF = Session["FashionFlavorSelected"] as List <FashionFlavor>; List <EventType> selectedET = (List <EventType>)Session["EventTypeSelected"]; if (selectedFF != null) { List <Silouhette> silouhettes = silouhetteRepository.GetByFlavors(selectedFF, selectedET) as List <Silouhette>; if (silouhettes != null) { IList <Fabric> fabrics = fabricRepository.GetForSilouhette(silouhettes[0], selectedET); Pattern solid = patternRepository.GetSolid(); List <Garment> garments = garmentRepository.GetBySelection(silouhettes[0], fabrics[0], solid, selectedET) as List <Garment>; ViewData["Silouhettes"] = silouhettes; ViewData["Garments"] = garments; ViewData["SilouhetteId"] = silouhettes[0].Id; ViewData["PatternId"] = solid.Id; ViewData["Patterns"] = patternRepository.GetAll(); ViewData["Fabrics"] = fabrics; ViewData["FabricId"] = fabrics[0].Id; } } return(View(selectedFF)); }