Beispiel #1
0
        public List <Suggestion> GetFirstSuggestions(UserBehaviorDatabase db, Databases.DomainModel.User user, int numSuggestions)
        {
            var userActionGroup = db.UserActions
                                  .GroupBy(x => new { x.UserID })
                                  .Select(g => new { g.Key.UserID })
                                  .ToList();

            List <Suggestion> suggestions = new List <Suggestion>();
            MongodbFunctions  mongo       = new MongodbFunctions();

            foreach (var a in userActionGroup)
            {
                Databases.DomainModel.User u = mongo.GetUser(a.UserID);

                if (u.Gender.Equals(user.Gender) || u.BirthDate.Year == user.BirthDate.Year)
                {
                    int        userIndex = ratings.UserIndexToID.IndexOf(u.Id);
                    List <int> products  = GetHighestRatedProductsForUser(userIndex).Take(3).ToList();

                    foreach (int productIndex in products)
                    {
                        ObjectId productId = ratings.ProductIndexToID[productIndex];
                        suggestions.Add(new Suggestion(u.Id, productId, ratings.Users[userIndex].ProductRatings[productIndex]));
                    }
                }
            }

            suggestions.Sort((c, n) => n.Rating.CompareTo(c.Rating));

            return(suggestions.Take(numSuggestions).ToList());
        }
Beispiel #2
0
        public JsonResult UpdateChart()
        {
            MongodbFunctions mongo = new MongodbFunctions();

            Database.DomainModel.User  user  = mongo.GetUser(User.Identity.Name);
            Database.DomainModel.Order order = mongo.GetOpenOrder(user.Id);//vraca opened order, samo 1 po useru moze da postoji

            int count;
            List <Database.DomainModel.ProductShow> products = new List <Database.DomainModel.ProductShow>();

            if (order == null)
            {
                count = 0;
            }
            else
            {
                count = order.Products.Count;

                foreach (MongoDBRef r in order.Products)
                {
                    Database.DomainModel.Product product = mongo.GetProduct(new ObjectId(r.Id.ToString()));

                    Database.DomainModel.ProductShow pr = new Database.DomainModel.ProductShow
                    {
                        Id    = product.Id.ToString(),
                        Name  = product.Name,
                        Price = product.Price
                    };

                    products.Add(pr);
                }
            }

            return(Json(new { number = count, prod = products }, JsonRequestBehavior.AllowGet));
        }
        public void DeleteProduct(string id)
        {
            MongodbFunctions mongo = new MongodbFunctions();
            ObjectId         objID = new ObjectId(id);

            mongo.DeleteProduct(objID);
        }
        public JsonResult ReturnSubcategories(string option)
        {
            MongodbFunctions mongo         = new MongodbFunctions();
            List <string>    subcategories = mongo.GetSubcategories(option);

            return(Json(new { subcat = subcategories }, JsonRequestBehavior.AllowGet));
        }
        public bool ActivateDiscount()
        {
            MongodbFunctions mongo = new MongodbFunctions();

            Databases.DomainModel.User user = mongo.GetUser(User.Identity.Name);
            bool sent = false;

            TimescaledbFunctions tdb = new TimescaledbFunctions();

            if (!tdb.ActivatedDiscount(user.Id.ToString()))
            {
                Databases.DomainModel.Notification notification = new Databases.DomainModel.Notification
                {
                    Content = "Poštovani, ostvarili ste popust od 10% na sledeću kupovinu, koji možete iskoristiti u roku od nedelju dana.",
                    Title   = "Popust 10%",
                    Date    = DateTime.Now.Date,
                    Tag     = "l_popust",
                    Read    = false,
                    User    = new MongoDB.Driver.MongoDBRef("users", user.Id)
                };

                tdb.SendNotification(user.Id.ToString(), mongo.AddNotification(notification, user.Email).ToString(), "l_popust");

                sent = true;
            }

            tdb.CloseConnection();
            return(sent);
        }
Beispiel #6
0
        public void AddToChart(string id)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            Database.DomainModel.User  user  = mongo.GetUser(User.Identity.Name);
            Database.DomainModel.Order order = mongo.GetOpenOrder(user.Id);

            if (order == null)
            {
                List <MongoDBRef> products = new List <MongoDBRef>();
                products.Add(new MongoDBRef("products", new ObjectId(id)));

                order = new Database.DomainModel.Order
                {
                    Date     = DateTime.Now,
                    Status   = "opened",
                    Products = products
                };

                mongo.AddUpdateOrder(order, user.Email, "add");
            }
            else
            {
                order.Products.Add(new MongoDBRef("products", new ObjectId(id)));
                mongo.AddUpdateOrder(order, user.Email, "update");
            }
        }
        public ActionResult Index()
        {
            MongodbFunctions mongo = new MongodbFunctions();

            var randomproducts = mongo.GetProducts();

            return(View(randomproducts));
        }
        public ActionResult ProductDetails(string id)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            if (id.Equals(""))
            {
                return(RedirectToAction("Home", "Index"));
            }

            Databases.DomainModel.Product product = mongo.GetProduct(new ObjectId(id));

            if (product != null)
            {
                if (User.IsInRole("User"))
                {
                    Databases.DomainModel.User user = mongo.GetUser(User.Identity.Name);
                    TimescaledbFunctions       tdb  = new TimescaledbFunctions();
                    tdb.ViewProduct(user.Id.ToString(), id);
                    List <ObjectId> customers = tdb.GetCustomersOfProduct(id);
                    List <Tuple <ObjectId, int> > ratingProducts = new List <Tuple <ObjectId, int> >();

                    foreach (ObjectId objectId in customers)
                    {
                        List <ObjectId> productsIds = tdb.GetBoughtProducts(objectId, id);

                        foreach (ObjectId prodId in productsIds)
                        {
                            if (!ratingProducts.Exists(x => x.Item1.Equals(prodId)))
                            {
                                ratingProducts.Add(new Tuple <ObjectId, int>(prodId, 0));
                            }
                            else
                            {
                                int index = ratingProducts.FindIndex(x => x.Item1.Equals(prodId));
                                ratingProducts.Insert(index, new Tuple <ObjectId, int>(prodId, ratingProducts[index].Item2 + 1));
                            }
                        }
                    }

                    tdb.CloseConnection();

                    ratingProducts.Sort((c, n) => n.Item2.CompareTo(c.Item2));
                    List <Databases.DomainModel.Product> products = new List <Databases.DomainModel.Product>();

                    foreach (Tuple <ObjectId, int> p in ratingProducts)
                    {
                        products.Add(mongo.GetProduct(p.Item1));
                    }

                    ViewBag.AlsoBought = products.Take(4).ToList();
                }
                return(View(product));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Beispiel #9
0
        public void DeleteOrder()
        {
            MongodbFunctions mongo = new MongodbFunctions();

            Database.DomainModel.User  user  = mongo.GetUser(User.Identity.Name);
            Database.DomainModel.Order order = mongo.GetOpenOrder(user.Id);

            mongo.DeleteOrder(order.Id);
        }
        public JsonResult GetSuggestions()
        {
            List <string> products = new List <string>();

            if (User.Identity.IsAuthenticated && User.IsInRole("User"))
            {
                MongodbFunctions           mongo = new MongodbFunctions();
                Databases.DomainModel.User user  = mongo.GetUser(User.Identity.Name);

                RecommendationEngine.Interfaces.IRater    rater    = new LinearRater(1.0, 5.0);
                RecommendationEngine.Interfaces.IComparer comparer = new CosineComparer();
                RecommendationEngine.Recommenders.ItemCollaborativeFilterRecommender recommender1 = new RecommendationEngine.Recommenders.ItemCollaborativeFilterRecommender(comparer, rater, 20);

                RecommendationEngine.Parsers.UserBehaviorDatabaseParser parser  = new RecommendationEngine.Parsers.UserBehaviorDatabaseParser();
                List <Databases.DomainModel.RecommenderAction>          actions = parser.LoadForSearch();
                RecommendationEngine.Parsers.UserBehaviorDatabase       db      = parser.LoadUserBehaviorDatabase(actions);

                recommender1.Train(db);

                List <RecommendationEngine.Objects.Suggestion> suggestions      = new List <RecommendationEngine.Objects.Suggestion>();
                List <Databases.DomainModel.Product>           CategoryProducts = new List <Databases.DomainModel.Product>();


                if (actions.Count(x => x.UserId.Equals(user.Id)) > 0)
                {
                    suggestions = recommender1.GetSuggestions(user.Id, 5);
                }
                else
                {
                    foreach (string subcat in user.Interests)
                    {
                        CategoryProducts.AddRange(mongo.GetCategoryProducts(subcat).Take(2));
                    }

                    foreach (Databases.DomainModel.Product p in CategoryProducts)
                    {
                        if (!products.Exists(x => x.Equals(p.Name)))
                        {
                            products.Add(p.Name);
                        }
                    }
                    suggestions = recommender1.GetFirstSuggestions(db, user, 5);
                }

                foreach (RecommendationEngine.Objects.Suggestion s in suggestions)
                {
                    Databases.DomainModel.Product product = mongo.GetProduct(s.ProductID);
                    if (!products.Exists(x => x.Equals(product.Name)))
                    {
                        products.Add(product.Name);
                    }
                }
            }

            return(Json(new { prods = products }, JsonRequestBehavior.AllowGet));
        }
Beispiel #11
0
        public JsonResult GetComments(string id)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            ObjectId objID = new ObjectId(id);

            Database.DomainModel.Product product = mongo.GetProduct(objID);
            List <MongoDBRef>            mess    = product.Messages;
            int    count = product.Messages.Count;
            string role;

            if (User.IsInRole("Admin"))
            {
                role = "Admin";
            }
            else
            {
                role = "User";
            }

            List <Database.DomainModel.MessageShow> comments = new List <Database.DomainModel.MessageShow>();
            List <Database.DomainModel.UserShow>    users    = new List <Database.DomainModel.UserShow>();

            foreach (MongoDBRef r in mess)
            {
                Database.DomainModel.Message comment = mongo.GetComment(new ObjectId(r.Id.ToString()));
                Database.DomainModel.User    user    = mongo.GetUser(new ObjectId(comment.User.Id.ToString()));
                List <string> responses = new List <string>();

                foreach (MongoDBRef rr in comment.Responses)
                {
                    Database.DomainModel.AdminResponse response = mongo.GetResponse(new ObjectId(rr.Id.ToString()));
                    responses.Add(response.Content);
                }

                Database.DomainModel.MessageShow messShow = new Database.DomainModel.MessageShow
                {
                    Id        = comment.Id.ToString(),
                    Content   = comment.Content,
                    Responses = responses
                };
                Database.DomainModel.UserShow userShow = new Database.DomainModel.UserShow
                {
                    Id      = user.Id,
                    Name    = user.Name,
                    Surname = user.Surname,
                    Email   = user.Email,
                    Phone   = user.Phone,
                    Address = user.Address
                };
                comments.Add(messShow);
                users.Add(userShow);
            }

            return(Json(new { number = count, status = role, com = comments, people = users }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult AverageGrade(string id)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            ObjectId objID = new ObjectId(id);

            List <double> lista = mongo.AverageGrade(objID);

            return(Json(new { number = lista[1], grade = lista[0] }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult ReadNotification(string notId)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            Databases.DomainModel.Notification notification = mongo.GetNotification(new ObjectId(notId));

            mongo.UpdateNotificationStatus(new ObjectId(notId));

            return(Json(new { date = notification.Date.ToString("dd/MM/yyyy"), content = notification.Content, tag = notification.Tag }, JsonRequestBehavior.AllowGet));
        }
Beispiel #14
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    // Code for adding admins to db
                    var roleStore   = new RoleStore <IdentityRole>(new ApplicationDbContext());
                    var roleManager = new RoleManager <IdentityRole>(roleStore);
                    await roleManager.CreateAsync(new IdentityRole("User"));

                    await UserManager.AddToRoleAsync(user.Id, "User");

                    // Uncomment to add admin
                    //await roleManager.CreateAsync(new IdentityRole("Admin"));
                    //await UserManager.AddToRoleAsync(user.Id, "Admin");
                    //////////////////////////////////////////////////////


                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);


                    // Adding user to mongodb
                    MongodbFunctions mongo = new MongodbFunctions();

                    Database.DomainModel.User newUser = new Database.DomainModel.User
                    {
                        Email   = model.Email,
                        Name    = model.FirstName,
                        Phone   = model.Phone,
                        Surname = model.Surname
                    };
                    newUser.Address.Add(model.Address);

                    mongo.InsertUser(newUser);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #15
0
        public ActionResult SearchProduct(string name)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            if (name.Equals(""))
            {
                return(RedirectToAction("Home", "Index"));
            }

            return(View(mongo.SearchForProductsByName(name)));
        }
        public ActionResult CategoryProducts(string category)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            if (category.Equals(""))
            {
                return(RedirectToAction("Home", "Index"));
            }

            ViewBag.categoryName = category;
            return(View(mongo.GetCategoryProducts(category)));
        }
        public void AddComment(string prodId, string content)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            Databases.DomainModel.Message newMessage = new Databases.DomainModel.Message
            {
                Content = content,
                Product = new MongoDBRef("products", new ObjectId(prodId))
            };

            mongo.AddComment(newMessage, prodId, User.Identity.Name);
        }
Beispiel #18
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    // Code for users to db
                    var roleStore   = new RoleStore <IdentityRole>(new ApplicationDbContext());
                    var roleManager = new RoleManager <IdentityRole>(roleStore);
                    await roleManager.CreateAsync(new IdentityRole("User"));

                    await UserManager.AddToRoleAsync(user.Id, "User");

                    // Uncomment to add admin
                    //await roleManager.CreateAsync(new IdentityRole("Admin"));
                    //await UserManager.AddToRoleAsync(user.Id, "Admin");
                    //////////////////////////////////////////////////////


                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);


                    // Adding user to mongodb
                    MongodbFunctions mongo = new MongodbFunctions();

                    Databases.DomainModel.User newUser = new Databases.DomainModel.User
                    {
                        Email     = model.Email,
                        Name      = model.FirstName,
                        BirthDate = model.BirthDate,
                        Phone     = model.Phone,
                        Surname   = model.Surname,
                        Gender    = model.Gender,
                        Interests = model.Interests.Where(x => x.Value == true).Select(x => x.Key).ToList()
                    };
                    newUser.Address.Add(model.Address);

                    mongo.InsertUser(newUser);

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #19
0
        public void AddReview(string id, double grade, string comment)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            Database.DomainModel.Review newReview = new Database.DomainModel.Review
            {
                Grade   = grade,
                Comment = comment,
                Product = new MongoDBRef("products", new ObjectId(id))
            };

            mongo.AddReview(newReview, id, User.Identity.Name);
        }
        public ActionResult SearchProduct(string name)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            if (name.Equals(""))
            {
                return(RedirectToAction("Home", "Index"));
            }

            List <Databases.DomainModel.Product> products = mongo.SearchForProductsByName(name);

            return(View(products));
        }
        public void AddResponse(string id, string content)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            ObjectId messId = new ObjectId(id);

            Databases.DomainModel.AdminResponse newResponse = new Databases.DomainModel.AdminResponse
            {
                Content = content,
                Message = new MongoDBRef("messages", messId)
            };

            mongo.AddResponse(newResponse, messId);
        }
        public JsonResult GetReviews(string id)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            ObjectId objID = new ObjectId(id);

            Databases.DomainModel.Product product = mongo.GetProduct(objID);
            List <MongoDBRef>             rev     = product.Reviews;
            int count = product.Reviews.Count;

            List <Databases.DomainModel.ReviewShow> reviews = new List <Databases.DomainModel.ReviewShow>();
            List <Databases.DomainModel.UserShow>   users   = new List <Databases.DomainModel.UserShow>();

            foreach (MongoDBRef r in rev)
            {
                Databases.DomainModel.Review review = mongo.GetReview(new ObjectId(r.Id.ToString()));
                Databases.DomainModel.User   user   = mongo.GetUser(new ObjectId(review.User.Id.ToString()));

                Databases.DomainModel.UserShow userShow = new Databases.DomainModel.UserShow
                {
                    Id      = user.Id,
                    Name    = user.Name,
                    Surname = user.Surname,
                    Email   = user.Email,
                    Address = user.Address
                };

                Databases.DomainModel.ReviewShow reviewShow = new Databases.DomainModel.ReviewShow
                {
                    Id      = review.Id,
                    Grade   = review.Grade,
                    Comment = review.Comment
                };
                reviews.Add(reviewShow);
                users.Add(userShow);
            }

            if (User.IsInRole("User"))
            {
                Databases.DomainModel.User u = mongo.GetUser(User.Identity.Name);

                TimescaledbFunctions tdb = new TimescaledbFunctions();
                tdb.SeeReviews(u.Id.ToString(), id);
                tdb.CloseConnection();
            }

            return(Json(new { number = count, revs = reviews, people = users }, JsonRequestBehavior.AllowGet));
        }
Beispiel #23
0
        public UserBehaviorDatabase LoadUserBehaviorDatabase(List <Databases.DomainModel.RecommenderAction> actions)
        {
            UserBehaviorDatabase db    = new UserBehaviorDatabase();
            MongodbFunctions     mongo = new MongodbFunctions();

            db.Categories = mongo.GetCategories();
            db.Users      = mongo.GetUsers();
            db.Products   = mongo.GetProducts();

            foreach (Databases.DomainModel.RecommenderAction a in actions)
            {
                db.UserActions.Add(new Objects.UserAction(a.Action, a.UserId, a.ProductId, a.Grade));
            }

            return(db);
        }
        public void AddNewAdvert(string categories)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            var    picture = Request.Files["picture"];
            string path    = System.IO.Path.Combine(Server.MapPath("~/Resources/Adverts"), picture.FileName);

            picture.SaveAs(path);

            Databases.DomainModel.Advert newAdvert = new Databases.DomainModel.Advert
            {
                Picture       = picture.FileName,
                Subcategories = JsonConvert.DeserializeObject <List <string> >(categories)
            };

            mongo.InsertAd(newAdvert);
        }
        public void AddReview(string id, int grade, string comment)
        {
            MongodbFunctions     mongo = new MongodbFunctions();
            TimescaledbFunctions tdb   = new TimescaledbFunctions();

            Databases.DomainModel.User   user   = mongo.GetUser(User.Identity.Name);
            Databases.DomainModel.Review review = mongo.GetReview(user.Id, new ObjectId(id));

            if (review == null)
            {
                Databases.DomainModel.Review newReview = new Databases.DomainModel.Review
                {
                    Grade   = grade,
                    Comment = comment,
                    Product = new MongoDBRef("products", new ObjectId(id))
                };

                mongo.AddReview(newReview, id, User.Identity.Name);

                tdb.ReviewProduct(user.Id.ToString(), id, grade);
            }
            else
            {
                mongo.UpdateReview(review.Id, grade, comment);
                tdb.UpdateReview(user.Id.ToString(), id, grade);
            }

            if (tdb.LowGrades(user.Id.ToString()) >= 4)
            {
                Databases.DomainModel.Notification notification = new Databases.DomainModel.Notification
                {
                    Content = "Poštovani, primetili smo da ste više proizvoda ocenili lošom ocenom. Ako želite da zamenite neki od njih, " +
                              "pozovite naš call centar i dogovorite se sa operaterom. Takođe, imate opciju popusta od 10% prilikom sledeće kupovine. " +
                              "Popust možete aktivirati klikom na link u ovom obaveštenju i važi nedelju dana. U jednom trenutku možete aktivirati samo jedan popust.",
                    Title = "Niste zadovoljni kupljenim proizvodima?",
                    Date  = DateTime.Now.Date,
                    Tag   = "lose_ocene",
                    Read  = false,
                    User  = new MongoDB.Driver.MongoDBRef("users", user.Id)
                };

                tdb.SendNotification(user.Id.ToString(), mongo.AddNotification(notification, user.Email).ToString(), "lose_ocene");
            }

            tdb.CloseConnection();
        }
Beispiel #26
0
        public void DeleteFromChart(string id)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            Database.DomainModel.User  user  = mongo.GetUser(User.Identity.Name);
            Database.DomainModel.Order order = mongo.GetOpenOrder(user.Id);

            order.Products.Remove(new MongoDBRef("products", new ObjectId(id)));

            if (order.Products.Count > 0)
            {
                mongo.RemoveProduct(order);
            }
            else
            {
                mongo.DeleteOrder(order.Id);
            }
        }
Beispiel #27
0
        public void SubmitOrder(string address, string note, string pay)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            Database.DomainModel.User  user  = mongo.GetUser(User.Identity.Name);
            Database.DomainModel.Order order = mongo.GetOpenOrder(user.Id);

            if (!user.Address.Contains(address))
            {
                user.Address.Add(address);
                mongo.UpdateAddresses(user);
            }

            order.Note         = note;
            order.PayingMethod = pay;
            order.Address      = address;

            mongo.CloseOrder(order);
        }
Beispiel #28
0
        public ActionResult ProductDetails(string id)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            if (id.Equals(""))
            {
                return(RedirectToAction("Home", "Index"));
            }

            ObjectId objID = new ObjectId(id);

            Database.DomainModel.Product product = mongo.GetProduct(objID);
            if (product != null)
            {
                return(View(product));
            }
            else
            {
                return(HttpNotFound());
            }
        }
        public void AddNewProduct(string name, string category, string subcategory, int price, string characteristics)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            var    picture = Request.Files["picture"];
            string path    = System.IO.Path.Combine(Server.MapPath("~/Resources"), name + System.IO.Path.GetExtension(picture.FileName));

            picture.SaveAs(path);

            Databases.DomainModel.Category cat        = mongo.GetCategory(category);
            Databases.DomainModel.Product  newProduct = new Databases.DomainModel.Product
            {
                Name            = name,
                Price           = price,
                Subcategory     = subcategory,
                Picture         = name + System.IO.Path.GetExtension(picture.FileName),
                Category        = new MongoDBRef("categories", cat.Id),
                Characteristics = JsonConvert.DeserializeObject <List <string> >(characteristics)
            };

            mongo.InsertProduct(newProduct, category);
        }
        public void EditProduct(string id, string name, int price)
        {
            MongodbFunctions mongo = new MongodbFunctions();

            ObjectId objID = new ObjectId(id);

            var    picture = Request.Files["picture"];
            string path;

            if (picture != null)
            {
                string savePath = System.IO.Path.Combine(Server.MapPath("~/Resources"), name + System.IO.Path.GetExtension(picture.FileName));
                picture.SaveAs(savePath);
                path = name + System.IO.Path.GetExtension(picture.FileName);
            }
            else
            {
                Databases.DomainModel.Product product = mongo.GetProduct(objID);
                path = product.Picture;
            }
            mongo.UpdateProduct(objID, name, price, path);
        }