public ActionResult CreateDeliverer(string name)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.DelivererCreate(name);
            return(Redirect("/Management"));
        }
        public ActionResult ChangeDelivererStatus(string id, bool available)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.DelivererSetAvailable(new MongoDB.Bson.ObjectId(id), available);
            return(Redirect("/Management"));
        }
        public ActionResult CreateCategory(string name)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.CategoryCreate(name);
            return(Redirect("/Management"));
        }
        public ActionResult DeleteCategory(string id)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.CategoryDelete(new MongoDB.Bson.ObjectId(id));
            return(Redirect("/Management"));
        }
        public ActionResult CreateDish(string category, string name, string description, int price)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.CategoryDishCreate(name, description, price, category);
            return(Redirect("/Management"));
        }
        public ActionResult DelivererAssign(string order, string deliverer)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.DelivererAssignDeliverer(new MongoDB.Bson.ObjectId(order), new MongoDB.Bson.ObjectId(deliverer));
            return(Redirect("/Management"));
        }
        public ActionResult CreateSupplement(string category, string name, int price)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.CategorySupplementCreate(name, price, category);
            return(Redirect("/Management"));
        }
        public ActionResult DeleteOrderFromHistory(string id)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.HistoryOrderDelete(new MongoDB.Bson.ObjectId(id));
            return(Redirect("/Management"));
        }
        public ActionResult MoveorderToHistory(string orderId, string delivererId)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.DelivererDeliver(new MongoDB.Bson.ObjectId(orderId), new MongoDB.Bson.ObjectId(delivererId));
            return(Redirect("/Management"));
        }
        public ActionResult DeleteDish(string name, string category)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            provider.CategoryDishRemove(name, category);
            return(Redirect("/Management"));
        }
        // GET: Management
        public ActionResult Index()
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();
            ManagementViewModel model    = new ManagementViewModel();

            model.orders     = provider.OrderGetAll();
            model.history    = provider.HistoryOrderGetAll();
            model.deliverers = provider.DelivererGetAll();
            model.categories = provider.CategoryGetAll();
            return(View(model));
        }
Exemplo n.º 12
0
        public ActionResult ProcessOrder(OrderFormViewModel form)
        {
            MongoDBDataProvider provider    = new MongoDBDataProvider();
            List <OrderedDish>  cart        = (List <OrderedDish>)Session["Cart"];
            List <Restaurant>   restaurants = provider.DistrictGet(form.district).restaurants;
            Restaurant          restaurant  = restaurants.ElementAt(new Random().Next() % restaurants.Count);

            provider.OrderCreate(form.name, form.adress, form.phone, form.price, DateTime.Now.ToString("dd-MM-yyyy"), restaurant.id, cart);
            cart.RemoveRange(0, cart.Count);
            return(new HttpStatusCodeResult(200));
        }
Exemplo n.º 13
0
        public ActionResult Index()
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();
            HomeViewModel       model    = new HomeViewModel();

            DBInitializer initializer = new DBInitializer();

            initializer.DeleteAllData();
            initializer.Initialize();

            model.categories = provider.CategoryGetAll();
            model.districts  = provider.DistrictGetAll();
            return(View(model));
        }
Exemplo n.º 14
0
        public void TestLoadTrieTreeFromMongoDB()
        {
            var mockProviderSetting = new Mock <IDataProviderSetting>();

            mockProviderSetting.Setup(s => s.Uri).Returns("mongodb://localhost:28001");
            mockProviderSetting.Setup(s => s.ProviderType).Returns("MongoDBDataProvider");
            mockProviderSetting.Setup(s => s.DBName).Returns("nameResearch");
            mockProviderSetting.Setup(s => s.CollectionName).Returns("placeNames");
            var      dataProvider = new MongoDBDataProvider(mockProviderSetting.Object);
            TrieTree tt           = TrieFactory.LoadFromDataProvider(dataProvider);

            Assert.IsNotNull(tt);
            Assert.IsNotNull(tt.Root);
            Assert.IsTrue(tt.Root.Children.Count > 100);
        }
Exemplo n.º 15
0
        public void TestLoadMongoDBDict_placeNames()
        {
            var mockProviderSetting = new Mock <IDataProviderSetting>();

            mockProviderSetting.Setup(s => s.Uri).Returns("mongodb://localhost:28001");
            mockProviderSetting.Setup(s => s.ProviderType).Returns("MongoDBDataProvider");
            mockProviderSetting.Setup(s => s.DBName).Returns("nameResearch");
            mockProviderSetting.Setup(s => s.CollectionName).Returns("placeNames");
            //mockProviderSetting.Setup(s => s.EntityType).Returns("text");
            var dataProvider = new MongoDBDataProvider(mockProviderSetting.Object);
            var dataList     = dataProvider.Load();

            Assert.IsNotNull(dataList);
            Assert.IsTrue(dataList.Count > 8000);
        }
Exemplo n.º 16
0
        public void TestLoadMongoDBDict_Surnames()
        {
            var mockProviderSetting = new Mock <IDataProviderSetting>();

            mockProviderSetting.Setup(s => s.Uri).Returns("mongodb://localhost:28001");
            mockProviderSetting.Setup(s => s.ProviderType).Returns("MongoDBDataProvider");
            mockProviderSetting.Setup(s => s.DBName).Returns("nameResearch");
            mockProviderSetting.Setup(s => s.CollectionName).Returns("surnames");
            mockProviderSetting.Setup(s => s.EntityType).Returns("BluePrint.Dictionary.Entities.NameEntity,BluePrint.Dictionary");
            var dataProvider = new MongoDBDataProvider(mockProviderSetting.Object);
            var dataList     = dataProvider.Load();

            Assert.IsNotNull(dataList);
            Assert.IsTrue(dataList.Count > 500);
            Assert.IsFalse(string.IsNullOrEmpty(dataList[0].Word));
        }
Exemplo n.º 17
0
        public JsonResult AddToCart(CartEntryViewModel entry)
        {
            MongoDBDataProvider provider = new MongoDBDataProvider();

            if (Session["Cart"] == null)
            {
                Session["Cart"] = new List <OrderedDish>();
            }

            OrderedDish orderedDish = new OrderedDish();
            Category    tmpCat      = provider.CategoryGet(entry.category);

            orderedDish.price    = 0;
            orderedDish.dish     = tmpCat.dishes.Where(x => x.name == entry.dish).SingleOrDefault();
            orderedDish.quantity = entry.quantity;
            if (entry.supplements == null)
            {
                orderedDish.supplements = null;
            }
            else
            {
                orderedDish.supplements = new List <Supplement>();
                foreach (string supName in entry.supplements)
                {
                    foreach (Supplement catSup in tmpCat.supplements)
                    {
                        if (supName == catSup.name)
                        {
                            Supplement tmpSup = new Supplement();
                            tmpSup.name  = catSup.name;
                            tmpSup.price = catSup.price;
                            orderedDish.supplements.Add(tmpSup);
                            orderedDish.price += tmpSup.price;
                        }
                    }
                }
            }

            orderedDish.price += orderedDish.dish.price * orderedDish.quantity;
            List <OrderedDish> cart = (List <OrderedDish>)Session["Cart"];

            cart.Add(orderedDish);
            return(Json(cart));
        }
Exemplo n.º 18
0
        public void DeleteAllData()
        {
            MongoDBDataProvider dbMongo = new MongoDBDataProvider();

            dbMongo.DeleteAllData();
        }
Exemplo n.º 19
0
        public void Initialize()
        {
            string date = DateTime.Now.ToString("dd-MM-yyyy");

            MongoDBDataProvider dbMongo = new MongoDBDataProvider();

            StreamReader stream;

            //Check is database initialized
            if (dbMongo.CategoryGetAll().Count != 0)
            {
                return;
            }

            DeleteAllData();

            try
            {
                stream = new StreamReader(HostingEnvironment.MapPath(categoryFilePath));
                while (!stream.EndOfStream)
                {
                    Category category = new Category();
                    category.name = stream.ReadLine();
                    stream.ReadLine();
                    int         numofdishes = Convert.ToInt32(stream.ReadLine());
                    List <Dish> dishes      = new List <Dish>();
                    for (int i = 0; i < numofdishes; i++)
                    {
                        Dish dish = new Dish();
                        dish.name        = stream.ReadLine();
                        dish.description = stream.ReadLine();
                        dish.price       = Convert.ToInt32(stream.ReadLine());
                        dishes.Add(dish);
                    }
                    int numofsupplements          = Convert.ToInt32(stream.ReadLine());
                    List <Supplement> supplements = new List <Supplement>();
                    for (int i = 0; i < numofsupplements; i++)
                    {
                        Supplement supplement = new Supplement();
                        supplement.name  = stream.ReadLine();
                        supplement.price = Convert.ToInt32(stream.ReadLine());
                        supplements.Add(supplement);
                    }
                    category.dishes      = dishes;
                    category.supplements = supplements;
                    dbMongo.CategoryCreate(category.name);
                    foreach (Dish dish in category.dishes)
                    {
                        dbMongo.CategoryDishCreate(dish.name, dish.description, dish.price, category.name);
                    }
                    foreach (Supplement supplement in category.supplements)
                    {
                        dbMongo.CategorySupplementCreate(supplement.name, supplement.price, category.name);
                    }
                }
                stream.Close();
            }
            catch (Exception e)
            {
            }



            try
            {
                stream = new StreamReader(HostingEnvironment.MapPath(districtFilePath));
                while (!stream.EndOfStream)
                {
                    District district = new District();
                    district.name = stream.ReadLine();
                    int numofRestaurants = Convert.ToInt32(stream.ReadLine());
                    district.restaurants = new List <Restaurant>();
                    for (int i = 0; i < numofRestaurants; i++)
                    {
                        Restaurant restaurant = new Restaurant();
                        restaurant.name           = stream.ReadLine();
                        restaurant.address        = stream.ReadLine();
                        restaurant.coordinates    = new double[2];
                        restaurant.coordinates[0] = Convert.ToDouble(stream.ReadLine());
                        restaurant.coordinates[1] = Convert.ToDouble(stream.ReadLine());
                        district.restaurants.Add(restaurant);
                    }
                    dbMongo.DistrictCreate(district);
                }
                stream.Close();
            }
            catch (Exception e)
            {
            }
            dbMongo.DelivererCreate("Piter Parker");
            dbMongo.DelivererCreate("Tony Stark");
            dbMongo.DelivererCreate("Bruce Wayne");

            try
            {
                stream = new StreamReader(HostingEnvironment.MapPath(orderFilePath));
                while (!stream.EndOfStream)
                {
                    Order order = new Order();
                    order.name   = stream.ReadLine();
                    order.adress = stream.ReadLine();
                    order.phone  = stream.ReadLine();
                    order.price  = stream.ReadLine();
                    OrderedDish orderDish = new OrderedDish();
                    Dish        dish      = new Dish();
                    dish.name          = stream.ReadLine();
                    dish.description   = stream.ReadLine();
                    dish.price         = Convert.ToInt32(stream.ReadLine());
                    orderDish.dish     = dish;
                    orderDish.quantity = Convert.ToInt32(stream.ReadLine());
                    int numofsupplements          = Convert.ToInt32(stream.ReadLine());
                    List <Supplement> supplements = new List <Supplement>();
                    for (int i = 0; i < numofsupplements; i++)
                    {
                        Supplement supplement = new Supplement();
                        supplement.name  = stream.ReadLine();
                        supplement.price = Convert.ToInt32(stream.ReadLine());
                        supplements.Add(supplement);
                    }
                    orderDish.supplements = supplements;
                    order.orderedDish     = new List <OrderedDish> {
                        orderDish
                    };
                    List <Restaurant> restaurants = dbMongo.DistrictGet("Palilula").restaurants;
                    Restaurant        restaurant  = restaurants.ElementAt(new Random().Next() % restaurants.Count);
                    dbMongo.OrderCreate(order.name, order.adress, order.phone, order.price, date, restaurant.id, order.orderedDish);
                }
                stream.Close();
            }
            catch (Exception e)
            {
            }
        }
Exemplo n.º 20
0
 /// <summary>
 ///
 /// </summary>
 public MongoDBTests()
 {
     this.provider = new MongoDBDataProvider("mongodb://52.36.99.52:27017/test");
 }