Example #1
0
        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);
        }
Example #2
0
        public ViewResult Index(string updateFlavors)
        {
            if (ClosetState.Flavors == null)
            {
                Response.Redirect(Url.RouteUrl(new { controller = "FlavorSelect", action = "Index" }));
            }

            IList <FashionFlavor> lstFlavors = new List <FashionFlavor>();

            if (ClosetState.UserFlavors != null)
            {
                ViewData["UserFlavorSelected"] = ClosetState.UserFlavors;
            }

            IList <FashionFlavor> flavors = repFlavors.GetByIds((from f in ClosetState.Flavors select f.Id).ToList <int>());

            return(View(flavors));
        }
        public bool HasValidCombinations(IList <int> garments, IList <int> flavors)
        {
            try
            {
                string log = string.Empty;
                foreach (int i in garments)
                {
                    log += i.ToString() + ",";
                }

                logger.InfoFormat("Trying to combine these garments: {0}", log);
                processor.Garments       = garmentRepository.GetByIds(garments);
                processor.FashionFlavors = fashionFlavorRepository.GetByIds(flavors);

                bool result = processor.HasValidCombinations();
                logger.InfoFormat("Result of combining garments: {0}", result);
                return(result);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                throw ex;
            }
        }