Inheritance: MonoBehaviour
        private void _btnDeleteRowCloset_Click(object sender, RoutedEventArgs e)
        {
            var msg = MessageBox.Show("آیا میخواهید حذف شود؟", "پیغام", MessageBoxButton.OKCancel, MessageBoxImage.Question);

            switch (msg)
            {
            case MessageBoxResult.OK:
            {
                var    selected = _datagridCloset.SelectedItem;
                Closet cl       = (Closet)selected;
                db.Closets.Remove(cl);
                db.SaveChanges();
                _datagridCloset.ItemsSource = db.Closets.ToList();
                break;
            }

            case MessageBoxResult.Cancel:
                break;
            }
        }
Beispiel #2
0
        private void CreateIndex(Closet closet)
        {
#if !DEBUG
            //if (closet.Id == 144 || closet.Id == 30 || closet.Id == 11 || closet.Id == 2)
            //    return;

            //if (closet.Id != 144 && closet.Id != 30 && closet.Id != 11 && closet.Id != 2)
            //    return;
#endif
            using (SearchEngineService ses = SearchEngineService.GetByCloset(closet.Id))
            {
                int start = 0;
                int count = _closetOutfitRepository.GetCountByCloset(closet.Id);

                while (start < count)
                {
                    IList <SearchEngineEntry> lst = new List <SearchEngineEntry>();

                    IList <ClosetOutfit> lstOutfits = _closetOutfitRepository.GetByClosetPaged(closet.Id, start, Quantity);
                    if (lstOutfits == null)
                    {
                        break;
                    }

                    foreach (ClosetOutfit closetOutfit in lstOutfits)
                    {
                        SearchEngineEntry see = closetOutfit.ToSearchEngineEntry();
                        lst.Add(see);
                    }

                    ses.AddEntries(lst);

                    start += Quantity;
                    GC.Collect();
                }
            }

            NHibernateSession.Current.Clear();
            GC.Collect();
        }
        /// <summary>
        /// Validates if the user can access the Outfit
        /// </summary>
        /// <param name="bu"></param>
        /// <param name="co"></param>
        /// <returns></returns>
        public static bool CanViewClosetOutfit(BasicUser bu, ClosetOutfit co)
        {
            Closet c = co.Closet;

            if (bu != null && c.User.Id == bu.Id)
            {
                return(true);
            }

            bool isFriendOrFull = CanViewCloset(bu, c);

            if (isFriendOrFull)
            {
                return(true);
            }

            if (c.PrivacyLevel == PrivacyLevel.FavoriteOutfit && co.Id == co.Closet.FavoriteOutfit.Id)
            {
                return(true);
            }

            return(false);
        }
        public JsonResult AddToCloset(WishListSelection wls)
        {
            closetRepository.DbContext.BeginTransaction();
            // Remove from Wish List
            Garment  g  = new MasterGarment(wls.GarmentId);
            WishList wl = wishListRepository.GetForUser(this.ProxyLoggedUser);

            wl.RemoveWishGarment(new WishGarment(wls.WishListId));

            // Add to closet
            Closet c = closetRepository.Get(this.ClosetId);

            c.AddGarment(g);
            closetRepository.DbContext.CommitTransaction();

            List <int> ids = new List <int>();

            ids.Add(wls.GarmentId);
            // Update the closet combinations
            (new FashionAde.Utils.OutfitEngineService.OutfitEngineServiceClient()).AddOutfits(this.ClosetId, ids);

            return(Json(new { Success = true }));
        }
Beispiel #5
0
        public void IndexPendingOutfits(Closet closet)
        {
            IList <SearchEngineEntry> entries = new List <SearchEngineEntry>();

            var propertyValues = new Dictionary <string, object>();

            propertyValues.Add("Closet.Id", closet.Id);
            propertyValues.Add("Status", ClosetOutfitStatus.NotIndexed);

            IList <ClosetOutfit> lstNewOutfits = _closetOutfitRepository.FindAll(propertyValues);

            if (lstNewOutfits.Count > 0)
            {
                foreach (ClosetOutfit ou in lstNewOutfits)
                {
                    entries.Add(ou.ToSearchEngineEntry());
                }

                using (SearchEngineService ses = SearchEngineService.GetByCloset(closet.Id))
                    ses.AddEntries(entries);

                _closetOutfitRepository.ChangeStatus(closet.Id, ClosetOutfitStatus.NotIndexed, ClosetOutfitStatus.Ready);
            }
        }
Beispiel #6
0
        public void CanCreateWithOtherAccessories()
        {
            IClosetRepository cr = new ClosetRepository();

            IList <int> lst    = new List <int>();
            string      values = "89701,94771,95161,99451,100231,162241,162631,163021,179011,181351,184471,184861,189541,244921,246091,249991,251161,256621,277291,278461,283921,287431,588511,594361,599431,703171,707851,709021,713701,998401,1003471,1007761,1008151,1342381,1343551,1347451,1351351,1353691,2177371,2181661,2182051,2182831,2186731,2210521,2215201,2216371,2717911,2727661,2729611,2731171,2979991,2981551,2985061,2986621,3029131,3029521,3033811,3039661";

            foreach (string val in values.Split(','))
            {
                lst.Add(Convert.ToInt32(val));
            }

            cr.DbContext.BeginTransaction();
            Closet c = cr.Get(2);

            foreach (int i in lst)
            {
                c.AddGarment(new MasterGarment(i));
            }
            cr.SaveOrUpdate(c);
            cr.DbContext.CommitTransaction();

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

            lstFlavors.Add(1);
            lstFlavors.Add(5);

            IOutfitEngineService service = CreateOutfitEngineService();

            service.AddOutfits(2, lst);

            //IList<int> lstFlavors = new List<int>();
            //lstFlavors.Add(1);

            //Assert.IsTrue(service.HasValidCombinations(lst, lstFlavors));
        }
        public IList <PreCombination> GetNewsFor(Closet closet)
        {
            // We want to get Precombinations
            ICriteria crit = Session.CreateCriteria(typeof(PreCombination));

            // We need to reduce that set with the Precombination of the User Closet
            DetachedCriteria precombinations = DetachedCriteria.For(typeof(ClosetOutfit))
                                               .SetProjection(Projections.Property("PreCombination.Id"))
                                               .Add(Restrictions.Eq("Closet", closet));

            crit.Add(Subqueries.PropertyIn("Id", precombinations));

            // Make sure we only get non processed
            crit.Add(Restrictions.Eq("Status", PreCombinationStatus.New));

            // Fetch everything we can to avoid select on the loops.
            crit.SetFetchMode("Garment1", FetchMode.Join);
            crit.SetFetchMode("Garment1.Silouhette", FetchMode.Join);
            crit.SetFetchMode("Garment1.Silouhette.Structure", FetchMode.Join);
            crit.SetFetchMode("Garment1.Silouhette.Shape", FetchMode.Join);
            crit.SetFetchMode("Garment1.ColorFamily", FetchMode.Join);
            crit.SetFetchMode("Garment1.ColorFamily.AnalogousFamily", FetchMode.Join);
            crit.SetFetchMode("Garment1.ColorFamily.AnalogousFamily2", FetchMode.Join);
            crit.SetFetchMode("Garment1.ColorFamily.ComplimentaryFamily", FetchMode.Join);
            crit.SetFetchMode("Garment1.PatternType", FetchMode.Join);

            crit.SetFetchMode("Garment2", FetchMode.Join);
            crit.SetFetchMode("Garment2.Silouhette", FetchMode.Join);
            crit.SetFetchMode("Garment2.Silouhette.Structure", FetchMode.Join);
            crit.SetFetchMode("Garment2.Silouhette.Shape", FetchMode.Join);
            crit.SetFetchMode("Garment2.ColorFamily", FetchMode.Join);
            crit.SetFetchMode("Garment2.ColorFamily.AnalogousFamily", FetchMode.Join);
            crit.SetFetchMode("Garment2.ColorFamily.AnalogousFamily2", FetchMode.Join);
            crit.SetFetchMode("Garment2.ColorFamily.ComplimentaryFamily", FetchMode.Join);
            crit.SetFetchMode("Garment2.PatternType", FetchMode.Join);

            crit.SetFetchMode("Garment3", FetchMode.Join);
            crit.SetFetchMode("Garment3.Silouhette", FetchMode.Join);
            crit.SetFetchMode("Garment3.Silouhette.Structure", FetchMode.Join);
            crit.SetFetchMode("Garment3.Silouhette.Shape", FetchMode.Join);
            crit.SetFetchMode("Garment3.ColorFamily", FetchMode.Join);
            crit.SetFetchMode("Garment3.ColorFamily.AnalogousFamily", FetchMode.Join);
            crit.SetFetchMode("Garment3.ColorFamily.AnalogousFamily2", FetchMode.Join);
            crit.SetFetchMode("Garment3.ColorFamily.ComplimentaryFamily", FetchMode.Join);
            crit.SetFetchMode("Garment3.PatternType", FetchMode.Join);

            crit.SetFetchMode("Garment4", FetchMode.Join);
            crit.SetFetchMode("Garment4.Silouhette", FetchMode.Join);
            crit.SetFetchMode("Garment4.Silouhette.Structure", FetchMode.Join);
            crit.SetFetchMode("Garment4.Silouhette.Shape", FetchMode.Join);
            crit.SetFetchMode("Garment4.ColorFamily", FetchMode.Join);
            crit.SetFetchMode("Garment4.ColorFamily.AnalogousFamily", FetchMode.Join);
            crit.SetFetchMode("Garment4.ColorFamily.AnalogousFamily2", FetchMode.Join);
            crit.SetFetchMode("Garment4.ColorFamily.ComplimentaryFamily", FetchMode.Join);
            crit.SetFetchMode("Garment4.PatternType", FetchMode.Join);

            crit.SetFetchMode("Garment5", FetchMode.Join);
            crit.SetFetchMode("Garment5.Silouhette", FetchMode.Join);
            crit.SetFetchMode("Garment5.Silouhette.Structure", FetchMode.Join);
            crit.SetFetchMode("Garment5.Silouhette.Shape", FetchMode.Join);
            crit.SetFetchMode("Garment5.ColorFamily", FetchMode.Join);
            crit.SetFetchMode("Garment5.ColorFamily.AnalogousFamily", FetchMode.Join);
            crit.SetFetchMode("Garment5.ColorFamily.AnalogousFamily2", FetchMode.Join);
            crit.SetFetchMode("Garment5.ColorFamily.ComplimentaryFamily", FetchMode.Join);
            crit.SetFetchMode("Garment5.PatternType", FetchMode.Join);

            return(crit.List <PreCombination>());
        }
        private IList <ClosetOutfitGarmentView> GetComponentList(IList <ClosetOutfitView> outfits, Closet closet)
        {
            if (outfits.Count == 0)
            {
                return(new List <ClosetOutfitGarmentView>());
            }

            string where = " where ";

            string outfitIds = "";

            if (closet != null)
            {
                where    += "co.closetid= " + closet.Id;
                outfitIds = " and ";
            }
            outfitIds += "ClosetOutfitId in (";
            foreach (ClosetOutfitView closetOutfitView in outfits)
            {
                outfitIds += closetOutfitView.ClosetOutfitId + ",";
            }

            outfitIds = outfitIds.Substring(0, outfitIds.Length - 1) + ")";

            where += outfitIds;
            where += " and g.GarmentId != 0";
            int    i     = 1;
            string query = "";

            for (; i <= 13; i++)
            {
                query += "select `co`.`closetoutfitid` AS `ClosetOutfitId`,`g`.`Title` AS `Title`,`g`.`ImageUri` AS `ImageUri`,`g`.`GarmentId` AS `GarmentId` from (`closetoutfits` `co` join `garments` `g` on((`co`.`Garment" + i + "Id` = `g`.`GarmentId`))) " + where + " union ";
            }
            query = query.Substring(0, query.Length - 7);

            IQuery q = NHibernateSession.Current.CreateSQLQuery(query);

            q.SetResultTransformer(new NHibernate.Transform.AliasToBeanConstructorResultTransformer(typeof(ClosetOutfitGarmentView).GetConstructors()[1]));
            return(q.List <ClosetOutfitGarmentView>());
        }
        private IList <ClosetOutfitView> GetComponents(IList <ClosetOutfitView> result, Closet closet)
        {
            List <ClosetOutfitGarmentView> components = GetComponentList(result, closet) as List <ClosetOutfitGarmentView>;

            foreach (ClosetOutfitView outfitView in result)
            {
                outfitView.OutfitGarments.AddRange(components.FindAll(delegate(ClosetOutfitGarmentView record)
                {
                    if (record.ClosetOutfitId == outfitView.ClosetOutfitId && record.GarmentId != 0)
                    {
                        return(true);
                    }
                    return(false);
                }));

                outfitView.OutfitUpdater   = new OutfitUpdaterRepository().GetRandomOutfitUpdaterFor(outfitView.PreCombination);
                outfitView.ShortEventTypes = GetShortNames(new EventTypeRepository().GetByCode(ResolveBinaryCode(outfitView.EventTypes)));
            }
            return(result);
        }
Beispiel #10
0
        public bool RegisterMember(string email, string userName, string firstName, string lastName, string password,
                                   UserSize userSize, int membershipUserId, string zipCode,
                                   IList <UserFlavor> userFlavors, IList <EventType> eventTypes,
                                   IList <Garment> mygarments, IList <Garment> mywishlist,
                                   string validateUri, string channel,
                                   string invitationCode)
        {
            bool mustConfirmMail = true;

            try
            {
                IDictionary <string, object> propertyValues;
                bool invited = false;

                email    = email.ToLower().Trim();
                userName = userName.ToLower().Trim();

                basicUserRepository.DbContext.BeginTransaction();

                if (!string.IsNullOrEmpty(invitationCode))
                {
                    propertyValues = new Dictionary <string, object>();
                    propertyValues.Add("Code", invitationCode);
                    InvitationCode ic = invitationCodeRepository.FindOne(propertyValues);

                    if (!invitationValidatorService.IsValidCode(ic))
                    {
                        throw new InvalidInvitationCodeException();
                    }

                    mustConfirmMail = string.IsNullOrEmpty(ic.EmailAddress);
                    ic.MarkUsed();
                    invitationCodeRepository.SaveOrUpdate(ic);
                }

                RegisteredUser user = new RegisteredUser();
                user.UserName         = userName;
                user.FirstName        = firstName;
                user.LastName         = lastName;
                user.EmailAddress     = email.ToLower().Trim();
                user.Size             = userSize;
                user.PhoneNumber      = string.Empty;
                user.MembershipUserId = membershipUserId;
                user.RegistrationCode = Guid.NewGuid().ToString();  // Used for email verification purposes.
                user.ChangeZipCode(zipCode);
                user.SetFlavors(userFlavors);
                user.Channel = channel;

                if (eventTypes != null)
                {
                    foreach (EventType eventType in eventTypes)
                    {
                        user.AddEventType(eventType);
                    }
                }

                // Create Closet
                Closet closet = new Closet();
                closet.User         = user;
                closet.PrivacyLevel = PrivacyLevel.Private;
                closet.MarkAsProcessed();

                if (mygarments != null)
                {
                    foreach (Garment garment in mygarments)
                    {
                        closet.AddGarment(garment);
                    }
                }
                user.Closet = closet;

                // Check if the user does not exist with that mail
                propertyValues = new Dictionary <string, object>();
                propertyValues.Add("EmailAddress", email);
                BasicUser bu = basicUserRepository.FindOne(propertyValues);

                // HACK: We need to change the mail of the invited user to be able to add the new registered user.
                if (bu != null && bu is InvitedUser)
                {
                    InvitedUser iu = bu as InvitedUser;
                    iu.EmailAddressReplaced = iu.EmailAddress;
                    iu.EmailAddress        += new Random().Next().ToString();

                    basicUserRepository.SaveOrUpdate(iu);
                    basicUserRepository.DbContext.CommitTransaction();

                    basicUserRepository.DbContext.BeginTransaction();
                    closetRepository.SaveOrUpdate(closet);
                    basicUserRepository.SaveOrUpdate(user);

                    propertyValues = new Dictionary <string, object>();
                    propertyValues.Add("User", bu);
                    IList <Friend> lst = friendRepository.FindAll(propertyValues);
                    if (lst.Count > 0)
                    {
                        foreach (Friend f in lst)
                        {
                            Friend newFriend = new Friend();
                            newFriend.BasicUser = user;
                            newFriend.User      = f.BasicUser;
                            newFriend.Status    = FriendStatus.Pending;
                            friendRepository.SaveOrUpdate(newFriend);
                        }
                    }

                    invited = true;
                }
                else
                {
                    closetRepository.SaveOrUpdate(closet);
                    basicUserRepository.SaveOrUpdate(user);
                }

                // Create wishlist even if no items been selected for further use.
                WishList wl = new WishList();
                wl.User = user;

                // Save Wish List
                if (mywishlist != null && mywishlist.Count > 0)
                {
                    foreach (Garment wishlist in mywishlist)
                    {
                        wl.AddGarment(wishlist);
                    }
                }
                wishListRepository.SaveOrUpdate(wl);

                // Send Email Confirmation Mail
                if (mustConfirmMail)
                {
                    SendValidationCode(user, validateUri);
                }

                // Commit Transaction
                basicUserRepository.DbContext.CommitTransaction();

                new FashionAde.Utils.OutfitEngineService.OutfitEngineServiceClient().CreateOutfits(closet.Id);

                if (invited)
                {
                    basicUserRepository.MigrateInvited(bu as InvitedUser, user);
                }
            }
            catch
            {
                try { basicUserRepository.DbContext.RollbackTransaction(); }
                catch { }

                throw;
            }

            return(mustConfirmMail);
        }
Beispiel #11
0
        public ViewResult Register(UserRegistration userRegistration)
        {
            var errors = userRegistration.Validate();

            if (errors == null)
            {
                IList <UserFlavor> userFlavors = Session["UserFlavorSelected"] as List <UserFlavor>;
                IList <EventType>  eventTypes  = Session["EventTypeSelected"] as List <EventType>;
                IList <Garment>    mygarments  = Session["MyGarments"] as List <Garment>;
                IList <Garment>    mywishlist  = Session["MyWishList"] as List <Garment>;

                PublicUser user = new PublicUser();
                user.EmailAddress = userRegistration.Email;
                user.ChangeZipCode(userRegistration.ZipCode);
                user.SetFlavors(userFlavors);
                user.Size = new UserSize(Convert.ToInt32(userRegistration.UserSize));

                //TODO: Get the UserId from ASP.NET Membership
                MembershipCreateStatus status;
                MembershipUser         mu = Membership.CreateUser(userRegistration.UserName, userRegistration.Password, userRegistration.Email, securityQuestionRepository.Get(Convert.ToInt32(userRegistration.SecurityQuestion)).Description, userRegistration.SecurityAnswer, true, out status);
                if (status != MembershipCreateStatus.Success)
                {
                    errors = new ErrorSummary();
                    errors.RegisterErrorMessage("MembershipUser", status.ToString());
                    return(RegistrationError(userRegistration, errors.ErrorMessages));
                }
                user.MembershipUserId = Convert.ToInt32(mu.ProviderUserKey);
                user.FirstName        = string.Empty;
                user.LastName         = string.Empty;
                user.PhoneNumber      = string.Empty;

                if (eventTypes != null)
                {
                    foreach (EventType eventType in eventTypes)
                    {
                        user.AddEventType(eventType);
                    }
                }

                registeredUserRepository.SaveOrUpdate(user);
                Closet closet = new Closet();
                closet.User         = user;
                closet.PrivacyLevel = PrivacyLevel.Private;

                closetRepository.SaveOrUpdate(closet);
                if (mygarments != null)
                {
                    foreach (Garment garment in mygarments)
                    {
                        closet.AddGarment(garment);
                    }
                    closetRepository.SaveOrUpdate(closet);
                }
                user.Closet = closet;

                registeredUserRepository.SaveOrUpdate(user);

                if (mywishlist != null && mywishlist.Count > 0)
                {
                    WishList wl = new WishList();
                    wl.User = user;
                    foreach (Garment wishlist in mywishlist)
                    {
                        wl.AddGarment(wishlist);
                    }
                    wishListRepository.SaveOrUpdate(wl);
                }
                closetRepository.GenerateCloset(user);

                Session.Abandon();
                Session["UserRegistration"] = mu;
                return(View("RegistrationFinish", userRegistration));
            }

            return(RegistrationError(userRegistration, errors.ErrorMessages));
        }
 private void Awake()
 {
     if (!instance) instance = this;
 }
Beispiel #13
0
 public async Task AddAsync(Closet closet)
 {
     await _context.AddAsync(closet);
 }
Beispiel #14
0
        public IList <ClosetOutfitView> Search(out int totalCount, int pageSize, int pageNumber, int season, int userId, string search, string sortBy, Closet closet)
        {
            ICriteria crit = GetCrit(userId, season, search);

            crit.SetProjection(Projections.ProjectionList().Add(Projections.Count("Id")));
            totalCount = crit.UniqueResult <int>();
            if (totalCount == 0)
            {
                return(new List <ClosetOutfitView>());
            }

            crit = GetCrit(userId, season, search);
            crit.SetMaxResults(pageSize);

            if (pageNumber == -1)
            {
                if (totalCount % 10 > 0)
                {
                    pageNumber = (totalCount / pageSize) + 1;
                }
                else
                {
                    pageNumber = (totalCount / pageSize);
                }
            }

            crit.SetFirstResult((pageNumber * pageSize) - (pageSize));

            switch (sortBy)
            {
            case "1":
                crit.AddOrder(new Order("EditorRating", false));
                break;

            case "2":
                crit.AddOrder(new Order("MyRating", false));
                break;

            case "3":
                crit.AddOrder(new Order("AverageFriendRating", false));
                break;

            case "4":
                crit.AddOrder(new Order("WornDate", false));
                break;
            }

            return(GetComponents(crit.List <ClosetOutfitView>(), closet));
        }
 public override void Trigger()
 {
     Debug.Log("hiding");
     Closet.GetInstance().onPlayerHidden += PlayerHiddenHandler;
 }
Beispiel #16
0
        private IList <ClosetOutfitView> GetComponents(IList <ClosetOutfitView> result, Closet closet)
        {
            closetOutfitRepository = new ClosetOutfitRepository();
            List <ClosetOutfitGarmentView> components = closetOutfitRepository.GetComponentList(result, closet) as List <ClosetOutfitGarmentView>;

            foreach (ClosetOutfitView outfitView in result)
            {
                outfitView.OutfitGarments.AddRange(components.FindAll(delegate(ClosetOutfitGarmentView record)
                {
                    if (record.ClosetOutfitId == outfitView.ClosetOutfitId)
                    {
                        return(true);
                    }
                    return(false);
                }));
            }
            return(result);
        }
Beispiel #17
0
        private void GenerateButton_Click(object sender, EventArgs e)
        {
            // checken if product type is chosen.
            if (comboBox1.Text == "Selecteer soort")
            {
                MessageBox.Show("Er moet een soort worden aangegeven.", "Foutmelding", MessageBoxButtons.OK);
            }
            // Checking if boxes are filled.
            else if (NameBox.Text == "" || DescriptionBox.Text == "" || WidthBox.Text == "" || HeigthBox.Text == "" || PriceBox.Text == "")
            {
                MessageBox.Show("Alle velden moeten ingevuld zijn.", "Foutmelding", MessageBoxButtons.OK);
            }
            // Checking if lightbox is filled (only when product type is "Lamp").
            else if (comboBox1.SelectedItem.ToString() == "Lamp" && LightBox.Text == "")
            {
                MessageBox.Show("Alle velden moeten ingevuld zijn.", "Foutmelding", MessageBoxButtons.OK);
            }
            // Cheching if a image is uploaded.
            else if (image == null)
            {
                MessageBox.Show("Er moet een afbeelding worden meegegeven.", "Foutmelding", MessageBoxButtons.OK);
            }
            else
            {
                // Generate path project is based in.
                string workingPath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()));
                workingPath = Path.Combine(workingPath, "ProductImages");
                // Make the directory "ProductImages" if it doesnt exist.
                if (!Directory.Exists(workingPath))
                {
                    Console.WriteLine("Directory doesnt exist!");
                    Directory.CreateDirectory(workingPath);
                }
                // Move image if directory exists.
                if (Directory.Exists(workingPath))
                {
                    // Make unique image name so it doesnt overwrite
                    imageName = $@"{DateTime.Now.Ticks.GetHashCode().ToString("x").ToUpper()}.png";
                    // Copy the file to the base of this program.
                    string tempString = Path.Combine(workingPath, imageName);
                    Console.WriteLine(tempString);
                    pictureBox1.Image.Save(tempString);
                    Console.WriteLine("Directory exists!");
                }
                Product product = null;
                var     mc      = new MyContext();
                using (mc)
                {
                    // Checks the selected product type and adds that product to the database.
                    switch (comboBox1.SelectedItem.ToString())
                    {
                    case "Bank":
                        mc.products.Add(product = new Sofa(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Lamp":
                        mc.products.Add(product = new Lamp(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName, Int32.Parse(LightBox.Text)));
                        mc.SaveChanges();
                        break;

                    case "Essentiële":
                        mc.products.Add(product = new Essentials(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Stoel":
                        mc.products.Add(product = new Chair(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Plant":
                        mc.products.Add(product = new Plant(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Tafel":
                        mc.products.Add(product = new Table(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Wandaccesoire":
                        mc.products.Add(product = new WallAccessories(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;

                    case "Kast":
                        mc.products.Add(product = new Closet(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                        mc.SaveChanges();
                        break;
                    }
                }
                if (product == null)
                {
                    Console.WriteLine("Toegevoegd product == null");
                }
                else
                {
                    Console.WriteLine("Toegevoegd product active: " + product.active);
                }
                catalogPanel.catalogController.AddProductToVanillaList(product);
                catalogPanel.catalogController.RefreshDisplayedItems();
                MessageBox.Show("Het product is toegevoegd aan de catalogus.", "Succes", MessageBoxButtons.OK);
                Close();
            }
        }
Beispiel #18
0
        public ActionResult UploadFile(FormCollection values)
        {
            ArrayList           lst      = GetFormatedValues(values);
            RegisteredUser      user     = this.ProxyLoggedUser;
            IList <UserGarment> lstFiles = new List <UserGarment>();

            List <int> garmentsIds = new List <int>();

            userGarmentRepository.DbContext.BeginTransaction();

            for (int i = 0; i < Request.Files.Count - 1; i++)
            {
                HttpPostedFileBase uploadedFile = Request.Files[i];
                if (uploadedFile.ContentLength != 0)
                {
                    UserGarment ug = (UserGarment)lst[i];
                    ug.User     = user;
                    ug.ImageUri = "";
                    ug.LinkUri  = "";

                    // Find pregarment
                    IDictionary <string, object> propertyValues = new Dictionary <string, object>();
                    propertyValues.Add("Silouhette", ug.Tags.Silouhette);
                    propertyValues.Add("PatternType", ug.Tags.Pattern.Type);
                    propertyValues.Add("ColorFamily", ug.Tags.DefaultColor.Family);
                    ug.PreGarment = pregarmentRepository.FindOne(propertyValues);
                    ug.UpdateSeasonCode();
                    ug.UpdateEventTypeCode();
                    userGarmentRepository.SaveOrUpdate(ug);

                    FileInfo fi       = new FileInfo(uploadedFile.FileName);
                    string   fileName = "user_" + ug.Id.ToString() + fi.Extension;

                    string path          = ConfigurationManager.AppSettings["Resources_Path"];
                    string filePath      = Path.Combine(Path.Combine(path, @"Garments\UploadedImages\"), fileName);
                    string smallImgPath  = Path.Combine(Path.Combine(path, @"Garments\65\"), fileName);
                    string largelImgPath = Path.Combine(Path.Combine(path, @"Garments\95\"), fileName);

                    uploadedFile.SaveAs(filePath);

                    // TODO: Improve borders.
                    ImageHelper.MakeTransparent(filePath);

                    ResizeImage(filePath, largelImgPath, 135, 95, true); //Imagenes Grandes
                    ResizeImage(filePath, smallImgPath, 65, 65, true);   //Imagenes Pequeñas

                    ug.ImageUri = fileName;
                    userGarmentRepository.SaveOrUpdate(ug);
                    lstFiles.Add(ug);

                    Closet closet = closetRepository.Get(this.ClosetId);
                    closet.AddGarment(ug);
                    closetRepository.SaveOrUpdate(closet);

                    garmentsIds.Add(ug.Id);
                }
            }

            userGarmentRepository.DbContext.CommitTransaction();

            new FashionAde.Utils.OutfitEngineService.OutfitEngineServiceClient().AddOutfits(user.Closet.Id, garmentsIds);

            ViewData["uploadedFiles"] = lstFiles;
            return(View());
        }
Beispiel #19
0
 private void Destroy()
 {
     Closet.GetInstance().onClosetSound -= OnClosetSound;
 }
Beispiel #20
0
        //private Garment CreateGarment(PreGarment pregarment)
        //{
        //    Garment g = new Garment();
        //    SharpArch.Testing.EntityIdSetter.SetIdOf<int>(g, pregarment.Id);

        //    g.Tags.PreSilouhette = pregarment.Silouhette;
        //    g.Tags.Pattern = new Pattern { Type = pregarment.PatternType };
        //    g.Tags.Colors.Add(new Color { Family = pregarment.ColorFamily });

        //    foreach (Season season in Enum.GetValues(typeof(Season)))
        //        g.Tags.Seasons.Add(season);

        //    foreach (EventType eventType in eventTypeRepository.GetAll())
        //        g.Tags.EventTypes.Add(eventType);

        //    return g;
        //}

        #endregion

        /// <summary>
        /// Creates the necessary combinations for a current closet
        /// </summary>
        /// <param name="c">Current closet</param>
        public void RunOutfitGenerator(Closet c)
        {
            outfitEngineProcessor.EventTypes = c.User.EventTypes;

            foreach (UserFlavor uf in c.User.UserFlavors)
            {
                outfitEngineProcessor.FashionFlavors.Add(uf.Flavor);
            }

            //foreach (ClosetGarment g in c.Garments)
            //    outfitEngineProcessor.Garments.Add(g.Garment);

            outfitEngineProcessor.CreateCombinations();

            // TODO: Could be better to only get combinations for the event types to be processed right?
            // TODO: Outfits should be unique with the accesories, or not? OF COURSE!

            // TODO: The amount of combinations will keep growing and growing.... this will take too much time.
            //IList<Combination> dupPreCombs = combinationRepository.GetAll();
            //IList<Outfit> dupOufits = outfitRepository.GetAll();
            // IList<Combination> dupPreCombs = new List<Combination>();

            //int i = 0;
            //foreach (PreOutfit po in outfitEngineProcessor.Outfits)
            //{
            //    if (i == 0)
            //        combinationRepository.DbContext.BeginTransaction();

            //    PreCombination pc = po.Combination;

            //    Combination comb = new Combination();
            //    comb.AddComponent(pc.GarmentA);
            //    comb.AddComponent(pc.GarmentB);
            //    comb.AddComponent(pc.GarmentC);
            //    comb.AddComponent(pc.GarmentD);
            //    comb.AddComponent(pc.GarmentE);

            //    //int pos = dupPreCombs.IndexOf(comb);
            //    //if (pos >= 0)
            //    //    comb = dupPreCombs[pos];

            //    foreach (EventType et in pc.EventTypes)
            //        comb.AddEventType(et);

            //    foreach (FashionFlavor fv in pc.Flavors)
            //        comb.AddFashionFlavor(fv);

            //    foreach (Season se in pc.Seasons)
            //        comb.AddSeason(se);

            //    Outfit of = new Outfit { Combination = comb };
            //    of.AddAccesory(po.Accesory1);
            //    of.AddAccesory(po.Accesory2);
            //    of.AddAccesory(po.Accesory3);
            //    of.AddAccesory(po.Accesory4);
            //    of.AddAccesory(po.Accesory5);

            //    //pos = dupOufits.IndexOf(of);
            //    //if (pos >= 0) // This outfit already exist, just save the combination updated for now.
            //    //    combinationRepository.SaveOrUpdate(comb);
            //    //else

            //    combinationRepository.SaveOrUpdate(comb);
            //    outfitRepository.SaveOrUpdate(of);

            //    c.AddOutfit(of);
            //    i++;

            //    if (i == 500)
            //    {
            //        combinationRepository.DbContext.CommitTransaction();
            //        i = 0;
            //    }
            //}

            //if (i != 0)
            //    combinationRepository.DbContext.CommitTransaction();
        }
Beispiel #21
0
    public float suspicionThreshold;     // amount of volume where boyfriend gets suspicious

    private void Start()
    {
        Closet.GetInstance().onClosetSound += OnClosetSound;
    }
Beispiel #22
0
 public void UpdateCloset(Closet closet)
 {
     _context.Entry(closet).State = EntityState.Modified;
 }