This object describe restaurants.
Наследование: BaseSearchableEnabledItem, IEntity
Пример #1
0
        public OperatorMap FindOperatorMapsByRestName(RestaurantBasicData rest)
        {
            var namesWordsArray = rest.Name == null ? new string[] { } : Regex.Split(rest.Name, @"\W+");
            //var namesWordsArray = rest.Name == null ? new string[] { } : Regex.Split(rest.Name, @"(\w+'\w+)|(\W)");
            List<string> restNameWords = new List<string>(namesWordsArray);
            var descWordsArray = rest.Description == null ? new string[] { } : Regex.Split(rest.Description, @"\W+");
            //var descWordsArray = rest.Description == null ? new string[] { } : Regex.Split(rest.Description, @"(\w+'\w+)|(\W)");
            List<string> restDescriptionWords = new List<string>(descWordsArray);

            var allWords = restNameWords.Union(restDescriptionWords);
            List<OperatorMap> returnedOperators = new List<OperatorMap>();
            foreach (string word in allWords)
            {
                if (word.Length > 3)
                {
                    var foundOperator = OperatorMapSearch(word);
                    if (foundOperator != null)
                    {
                        returnedOperators.Add(foundOperator);
                    }
                }
            }
            if (returnedOperators.Count == 0) return null;
            if (returnedOperators.Count > 1) log.WarnFormat("[FindOperatorMapsByRestName] Warning: Count of found operatorMaps is > 1.");
            return returnedOperators[0];
        }
        public void CuisineMapSearchTest_IfRestCuisineContainsSimbols_ShouldTryToSplitCuisineToListAndFindAllCuisines()
        {
            RestaurantBasicData rest1 = new RestaurantBasicData()
            {
                Cuisine = "Falafel/Hummus"
            };
            RestaurantBasicData rest2 = new RestaurantBasicData()
            {
                Cuisine = "ice_cream;pizza;yogurt"
            };
            RestaurantBasicData rest3 = new RestaurantBasicData()
            {
                Cuisine = "fish, meat",
                Cuisines = new List<string>() { "meat" }
            };

            //Act
            var result1 = cuisineServices.CuisineMapSearch(rest1);
            var result2 = cuisineServices.CuisineMapSearch(rest2);
            var result3 = cuisineServices.CuisineMapSearch(rest3);

            //Assert
            Assert.IsNotNull(result1);
            Assert.IsNotNull(result2);
            Assert.IsNotNull(result3);
            Assert.IsTrue(result1.Count == 2);
            Assert.IsTrue(result2.Count == 2);
            Assert.IsTrue(result3.Count == 2);
        }
        public void GetCuisines_ShoulfUpdateCuisinesListInRestaurant()
        {
            ClassifyResult result1 = new ClassifyResult()
            {
                Result = "falafel",
                Propability = 0.86
            };
            ClassifyResult result2 = new ClassifyResult()
            {
                Result = "shawarma",
                Propability = 0.74
            };
            List<ClassifyResult> restultsList = new List<ClassifyResult>(){ result1, result2 };
            RestaurantBasicData rest = new RestaurantBasicData()
            {
                Name = "Test restaurant"
            };
            GetCuisinesByClassifierResults getCuisines = new GetCuisinesByClassifierResults(rest, restultsList);
            var resultRest = getCuisines.GetCuisines();

            Assert.IsNotNull(resultRest.Cuisines);
            Assert.IsNotNull(rest.Cuisines);
            Assert.IsTrue(resultRest.Cuisines.Count == 2);
            Assert.IsTrue(rest.Cuisines.Count == 2);
        }
Пример #4
0
 /// <summary>
 /// Check each OperatorMap name if containes in part of Restaurant Name or Description
 /// </summary>
 /// <param name="rest"></param>
 /// <returns></returns>
 public List<OperatorMap> FindOperatorMapByPartOfName(RestaurantBasicData rest)
 {
     string restName = rest.Name != null ? rest.Name : "";
     string restDescription = rest.Description != null ? rest.Description : "";
     if (restName != "")
     {
         List<OperatorMap> returnList = new List<OperatorMap>();
         List<OperatorMap> allOperatorMaps = GetAllOperatorMaps();
         if (allOperatorMaps != null)
         {
             foreach (var OperatorMap in allOperatorMaps)
             {
                 foreach (var OperatorName in OperatorMap.NamesList)
                 {
                     if (restName.IndexOf(OperatorName, StringComparison.OrdinalIgnoreCase) >= 0 || restDescription.IndexOf(OperatorName, StringComparison.OrdinalIgnoreCase) >= 0)
                     {
                         if (!returnList.Any(c => c.Name == OperatorMap.Name)) returnList.Add(OperatorMap);
                     }
                 }
             }
         }
         return returnList;
     }
     return null;
 }
Пример #5
0
 public static string BuildSearchQueryString(RestaurantBasicData rest)
 {
     string query = "";
     if (!string.IsNullOrEmpty(rest.Name)) query += rest.Name;
     if (rest.Adress != null && !string.IsNullOrEmpty(rest.Adress.City)) query += " " + rest.Adress.City;
     query += " סיווג";
     string returnStr = query.Replace(".", string.Empty);
     return returnStr;
 }
Пример #6
0
 /// <summary>
 /// Build query with BuildSearchQueryString function and execute google Custom Search
 /// </summary>
 /// <param name="rest"></param>
 /// <param name="withRestaurantUpdate"> bool parameter for save results in Restaurants DB</param>
 /// <returns></returns>
 public List<WebSearchResult> GoogleSearchRestaurantDescription(RestaurantBasicData rest, bool withRestaurantUpdate = false)
 {
     string query = BuildSearchQueryString(rest);
     var searchResults = searchUtilities.SearchQuery(query);
     if (searchResults != null && withRestaurantUpdate)
     {
         AddSearchToRestaurant(rest, searchResults);
     }
     return searchResults;
 }
Пример #7
0
 public bool CheckForCorrectChainMenu(RestaurantBasicData rest)
 {
     if (rest != null)
     {
         if (rest.Menu != null && rest.Menu.MenuParts.Count > 2)
         {
             return true;
         }
     }
     return false;
 }
Пример #8
0
 private void AddSearchToRestaurant(RestaurantBasicData rest, List<WebSearchResult> searchResults)
 {
     if (searchResults != null)
     {
         rest.SearchResults = new List<WebSearchResult>();
         rest.SearchResults = searchResults;
         m_serviceLayer.UpdateRestaurant(rest);
     }
     else
     {
         log.WarnFormat("[AddSearchToRestaurant] SearchResults is null, rest.Name={0}, rest.Description={1}, rest.Description={2}.", rest.Name, rest.Description, rest.Id.ToString());
     }
 }
        public RestaurantInfoClassificator(RestaurantBasicData rest, string classifierName)
        {
            if (rest == null)
                throw new ArgumentException("Can't create RestaurantInfoClassificator: Source cannot be null.");
            if (string.IsNullOrEmpty(rest.Name))
                throw new ArgumentException("Can't create RestaurantInfoClassificator: Restaurant Name cannot be null or empty.");
            if (string.IsNullOrEmpty(classifierName))
                throw new ArgumentException("Can't create RestaurantInfoClassificator: classifierName cannot be null or empty.");

            log.DebugFormat("[RestaurantInfoClassificator] Constructor: rest.Name={0}, rest.Id={1}, classifierName={2}.", rest.Name, rest.Id.ToString(), classifierName);
            restaurant = rest;
            classifyQuery = new RestaurantQueryPattern(restaurant);
            this.classifier = classifierName;
        }
        public void CuisineMapSearchTest_IfRestHasListOfCuisines_ShouldReturnListOfCuisine_WithoutDuplicates()
        {
            var rest1 = new RestaurantBasicData()
            {
                Cuisine = "italian",
                Cuisines = new List<string>() { "italian", "pizza", "drinks", "drinks" }
            };

            //Act
            var result1 = cuisineServices.CuisineMapSearch(rest1);

            //Assert
            Assert.IsNotNull(result1);
            Assert.IsTrue(result1.Count == 3);
        }
 /// <summary>
 /// Build query with BuildSearchQueryString function and execute google Custom Search
 /// </summary>
 /// <param name="rest"></param>
 /// <param name="withRestaurantUpdate"> bool parameter for save results in Restaurants DB</param>
 /// <returns></returns>
 public List<WebSearchResult> GoogleSearchRestaurantDescription(RestaurantBasicData rest)
 {
     try
     {
         string query = BuildSearchQuery.BuildSearchQueryString(rest);
         var searchResults = utilities.SearchQuery(query);
         string searchResultsCount = searchResults != null ? searchResults.Count.ToString() : "0";
         log.DebugFormat("[GoogleSearchRestaurantDescription] rest.Name={0}, rest.Id={1}, query={2}, searchResults.Count={3}.", rest.Name, rest.Id.ToString(), query, searchResultsCount);
         return searchResults;
     }
     catch (Exception e)
     {
         log.ErrorFormat("[GoogleSearchRestaurantDescription] Exception={0}.", e.Message);
         return null;
     }
 }
        //public List<ClassifyResult> bestResults { get; private set; }
        //private WebSearchResult bestSearchResult{ get; set; }
        public SearchEngineResultClassificator(RestaurantBasicData rest, string classifierName)
        {
            if (rest == null)
                throw new ArgumentException("Can't create SearchEngineResultClassificator: Source cannot be null.");
            if (string.IsNullOrEmpty(rest.Name))
                throw new ArgumentException("Can't create SearchEngineResultClassificator: Restaurant Name cannot be null or empty.");
            if (string.IsNullOrEmpty(classifierName))
                throw new ArgumentException("Can't create SearchEngineResultClassificator: classifierName cannot be null or empty.");

            log.DebugFormat("[SearchEngineResultClassificator] Constructor: rest.Name={0}, rest.Id={1}, classifierName={2}.", rest.Name, rest.Id.ToString(), classifierName);
            restaurant = rest;
            classifyQuery = new RestaurantQueryPattern(rest);
            searchQuery = BuildSearchQuery.BuildSearchQueryString(rest);
            classifier = classifierName;
            classificationResults = new List<WebSearchClassifyResult>();
        }
        public void ClassifyTest_ShouldReturnNotEmptyResults()
        {
            RestaurantBasicData rest = new RestaurantBasicData()
            {
                Name = "פלאפל ג'ינה",
                Adress = new Address() { City = "תל אביב" }
            };
            string classifierName = "CuisinesSupervised1";

            SearchEngineResultClassificator searchClassifier = new SearchEngineResultClassificator(rest, classifierName);

            //act
            var results = searchClassifier.Classify();

            //Assert
            Assert.IsNotNull(results);
        }
        public void ClassifyTest_ShoulfExecuteClassificationAndReceiveResults_ResultsShoudBeNotNull()
        {
            RestaurantBasicData rest = new RestaurantBasicData()
            {
                Name = "Test restaurant",
                Description = "falafel",
                Id = new MongoDB.Bson.ObjectId()
            };
            string classifierName = "CuisinesSupervised1";

            //act
            RestaurantInfoClassificator restInfoClass = new RestaurantInfoClassificator(rest, classifierName);
            List<ClassifyResult> results = restInfoClass.Classify();

            //Assert
            Assert.IsNotNull(results);
            //Assert.IsFalse(results.Any(r => r.Propability <= 0.5));
        }
Пример #15
0
 public static void Update(RestaurantBasicData restaurant)
 {
     log.DebugFormat("[UpdateRestaurant(RestaurantBasicData)] RestaurantBasicData={0}.", restaurant.ToString());
     restaurant.UpdatedAt = DateTime.UtcNow;
     if (restaurant.Image == null)
     {
         RestaurantBasicData previousRest = GetRestaurantBasic.GetById(restaurant.Id.ToString());
         if (previousRest.Image != null)
         {
             restaurant.Image = previousRest.Image;
         }
     }
     using (Restaurants restaurantsDb = new Restaurants())
     {
         MongoEntityRepositoryBase<RestaurantBasicData> basicData =
                         new MongoEntityRepositoryBase<RestaurantBasicData>(restaurantsDb.DB);
         basicData.Update(restaurant);
     }
 }
Пример #16
0
        public TestRestaurants()
        {
            RestaurantBasicData rest1 = new RestaurantBasicData()
            {
                Name = "עצל רוני",
                Description = "פלאפל",
                Adress = new Address(){ City = "נתניה" }
            };

            RestaurantBasicData rest2 = new RestaurantBasicData()
            {
                Name = "BBB",
                Description = "בורגרים",
                Adress = new Address() { City = "נתניה" }
            };

            RestaurantBasicData rest3 = new RestaurantBasicData()
            {
                Name = "חסן",
                Description = "שווארמה",
                Adress = new Address() { City = "נתניה" }
            };

            RestaurantBasicData rest4 = new RestaurantBasicData()
            {
                Name = "רובינשטיין",
                Adress = new Address() { City = "נתניה" }
            };

            RestaurantBasicData rest5 = new RestaurantBasicData()
            {
                Name = "דבוש",
                Adress = new Address() { City = "תל אביב" }
            };

            restaurantsList = new List<RestaurantBasicData>(){ rest1, rest2, rest3, rest4, rest5 };
        }
Пример #17
0
        public void TestSaveImage_RestaurantImageDataShouldBeSavedInFile()
        {
            //Arrange
            var newFileName = @"C:\Users\Vadik\Dropbox\Work\Downloaded_AlGauchoIcon.jpg";
            ImageData imageData = new ImageData();
            //Dish dishWithImages = new Dish();
            RestaurantBasicData restaurantWithImage = new RestaurantBasicData();

            MongoGridFSFileInfo uploadedFile;
            using (var fs = new FileStream(fileName, FileMode.Open))
            {
                uploadedFile = restaurantWithImage.UploadImageToRestaurant(m_Testdb.GridFS, fs, fileName, fileContentType);
            }

            //act
            //save image to file
            var file = m_Testdb.GridFS.FindOne(Query.EQ("_id", restaurantWithImage.Image.Id));

            using (var stream = file.OpenRead())
            {
                var bytes = new byte[stream.Length];
                stream.Read(bytes, 0, (int)stream.Length);
                using (var newFs = new FileStream(newFileName, FileMode.Create))
                {
                    newFs.Write(bytes, 0, bytes.Length);
                }
            }
            //open source and saved files
            var source = new FileStream(fileName, FileMode.Open);
            var savedFile = new FileStream(newFileName, FileMode.Open);

            //assert
            Assert.AreEqual(source.Length, savedFile.Length);
        }
Пример #18
0
 public RestaurantQueryPattern(RestaurantBasicData restData)
 {
     if (restData.Name != null) this.Name = restData.Name;
     if (restData.Description != null) this.Description = restData.Description;
 }
Пример #19
0
        public void AddDefaultMenuToRestaurant(RestaurantBasicData rest) 
        {
            try
            {
                if (rest != null)
                {
                    string cuisinesList = rest.Cuisines != null ? String.Join(", ", rest.Cuisines.ToArray()) : "Empty";
                    var TempMenus = GetDefaultMenusList(rest);
                    if (TempMenus != null && TempMenus.Count > 0)
                    {
                        ServiceLayerImpl serviceLayer = new ServiceLayerImpl();
                        rest.Menu = CombineMenus(TempMenus);
                        log.InfoFormat("[AddDefaultMenuToRestaurant] Found default Menu for rest.Name={0}, rest.Id={1}, Cuisines List={2}.", rest.Name, rest.Id.ToString(), cuisinesList);
                        rest.UpdateDishesLocation();
                        serviceLayer.UpdateRestaurant(rest);
                    }
                    else 
                    {
                        log.InfoFormat("[AddDefaultMenuToRestaurant] Not found default Menu for rest.Name={0}, rest.Id={1}, Cuisines List={2}.", rest.Name, rest.Id.ToString(), cuisinesList);
                    }

                }
                else 
                {
                    log.WarnFormat("[AddDefaultMenuToRestaurant] input restayrant is null.");
                }
            }
            catch (Exception e) 
            {
                log.ErrorFormat("[AddDefaultMenuToRest] Exception={0}.", e.Message);
            }
        }
Пример #20
0
 public List<Menu> GetDefaultMenusList(RestaurantBasicData rest)
 {
     List<Menu> menusList = new List<Menu>();
     if (rest.Cuisines != null && rest.Cuisines.Count > 0)
     {
         List<string> cuisinesList = new List<string>();
         if (rest.Source != null && rest.Source.IndexOf("BackOffice", StringComparison.OrdinalIgnoreCase) >= 0) cuisinesList = rest.Cuisines;
         else 
         {
             cuisinesList = CheckCuisineSafety(rest.Cuisines);
         }
         Menu tempMenu = GetDefaultMenuFromCuisinesList(cuisinesList);
         if (tempMenu != null && tempMenu.MenuParts != null && tempMenu.MenuParts.Count > 0) menusList.Add(tempMenu);
     }
     if(menusList.Count > 0) return menusList;
     return null;
 }
Пример #21
0
        public void TestSaveRestaurant()
        {
            //arrange
            MongoEntityRepositoryBase<RestaurantBasicData> mongoRepository = new MongoEntityRepositoryBase<RestaurantBasicData>(m_Testdb);
            RestaurantBasicData someTestyRestaurnat = new RestaurantBasicData()
            {
                Description = "משהו בעברית וארווווווווווווך",
                //Id = Guid.NewGuid().ToString(),
                ItemLocation = new Location() { Latitude = 1.001, Longitude = 2.001 },
                MappedState = new SuspiciousState() { Index = 100 },
                Name = "מסעדת רן ודניאל",
            };

            //Act
            try
            {
                mongoRepository.Add(someTestyRestaurnat);
            }
            catch (Exception ex)
            {

                Assert.Fail("oops, can't save", ex);
            }

            //Assert
            //If we got here everything is ok.
        }
        public void TestMenuClone_shouldCloneFullMenuFromOtheRestaurantAndInsteadOldMenu_OldMenuDeletted()
        {
            //arrange
            RestaurantBasicData restaurant1 = new RestaurantBasicData()
            {
                //arrange
                Id = ObjectId.Parse("50ae8b2a3720e80d085376db"),
                ItemLocation = new Location() { Latitude = 32.279296, Longitude = 34.860367 },
                Menu = new Menu()
            };
            RestaurantBasicData restaurant2 = new RestaurantBasicData()
            {
                //arrange
                Id = ObjectId.Parse("507d8f943720e807c045c442"),
                ItemLocation = new Location() { Latitude = 32, Longitude = 31 },
                Menu = new Menu()
            };

            Dish dish1 = new Dish()
            {
                Id = 1,
                Description = "סלט ירקות עם חתיכות חזה עוף",
                DishState = DishStateEnum.Active,
                Name = "סלט קיסר",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 30, Longitude = 27 },
                ImageUrl = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRqKcIkvCQDkCNQkXq0TWtiqRSF5ryYK7NYB79ZBVebpjKBVPcA",
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 7.77 },
                RecipeId = 10,
                State = new SuspiciousState() { Index = 7.77 },
                OverrideIngredients = new List<Ingredient>()
            };
            Dish dish2 = new Dish()
            {
                Id = 3,
                Description = "שניצל מוגש עם צ'יפס",
                DishState = DishStateEnum.Active,
                Name = "שניצל",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 31, Longitude = 29 },
                ImageUrl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQX5WBzP336hF8Q0FQpk5TdX8m7GI7ymVqJMtyrzSA3afEkqfU8CA",
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 8.88 },
                RecipeId = 28,
                State = new SuspiciousState() { Index = 8.88 },
                OverrideIngredients = new List<Ingredient>()
            };
            Dish dish3 = new Dish()
            {
                Id = 15,
                Description = "המבורגר 220גר עם צ'יפס בצד",
                DishState = DishStateEnum.Active,
                Name = "המבורגר",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 32, Longitude = 30 },
                ImageUrl = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTmEsDLKjW9dj_Vl8SMdESJkTBGncjY5QDt0sqK77txEUwSi2RzUA",
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 50 },
                RecipeId = 169,
                State = new SuspiciousState() { Index = 50 },
                OverrideIngredients = new List<Ingredient>()
            };
            Dish dish4 = new Dish()
            {
                Id = 4,
                Description = "חזה עך עם תוספת",
                DishState = DishStateEnum.Active,
                Name = "חזה עוף",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 32.89654, Longitude = 31.321 },
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 45.5 },
                RecipeId = 169,
                State = new SuspiciousState() { Index = 45.5 },
                OverrideIngredients = new List<Ingredient>()
            };
            MenuPart menuPart1 = new MenuPart() { Name = "עיקריות" };
            MenuPart menuPart2 = new MenuPart() { Name = "עיקריות" };
            menuPart1.Dishes.Add(dish1);
            menuPart1.Dishes.Add(dish2);
            menuPart1.Dishes.Add(dish3);
            menuPart2.Dishes.Add(dish4);
            restaurant1.Menu.MenuParts.Add(menuPart1);
            restaurant2.Menu.MenuParts.Add(menuPart2);

            //act

            restaurant2.MenuClone(restaurant1);

            //assert
            Assert.IsNull(restaurant2.Menu.MenuParts[0].Dishes.FirstOrDefault(d => d.Name=="חזה עוף"));
            foreach (var dish in restaurant1.Menu.MenuParts[0].Dishes)
            {
                Assert.IsNotNull(restaurant2.Menu.MenuParts[0].Dishes.FirstOrDefault(d => d.Name == dish.Name));
            }

            foreach (var dish in restaurant2.Menu.MenuParts[0].Dishes)
            {
                Assert.AreEqual(dish.ItemLocation, restaurant2.ItemLocation);
            }
        }
Пример #23
0
 public void MenuClone(RestaurantBasicData restCopyFrom)
 {
     this.Menu = restCopyFrom.Menu;
     this.UpdateDishesLocation();
 }
Пример #24
0
        private List<BaseSearchableEnabledItem> GetMockedSearchableItems()
        {
            Random rand = new Random();
            List<BaseSearchableEnabledItem> returnValue = new List<BaseSearchableEnabledItem>();

            for (int i = 0; i < 9; i++)
            {
                RestaurantBasicData searchableItem = new RestaurantBasicData()
                {
                    Description = "תיאור ממצא ואינפורמטיבי " + i,
                    Name = "מסעדה מס " + i,
                    MappedState = new SuspiciousState(),
                    ItemLocation = new Location() { Latitude = 32.089119 + (rand.NextDouble() - 0.5) / 100, Longitude = 34.873928 + (rand.NextDouble() - 0.5) / 200 }, // Deep-Systems office.,
                    Image = new ImageData(),
                };
                returnValue.Add(searchableItem);
            }

            return returnValue;
        }
        public void GetDishModelTest_ShouldReturnRestaurantModelWithDishModelBackOfficeIfCalledWithRestaurantModelBackOfficeParameter()
        {
            Dish dish1 = new Dish()
            {
                Name = "TempDish1",
                Description = "description",
                Id = 1,
                NutritionFacts = new NutritionFacts(),
                BaseLineNutritionFacts = new NutritionFacts()
            };
            Dish dish2 = new Dish()
            {
                Name = "TempDish2",
                Description = "description",
                Id = 2,
                NutritionFacts = new NutritionFacts(),
                BaseLineNutritionFacts = new NutritionFacts()
            };
            Dish dish3 = new Dish()
            {
                Name = "TempDish3",
                Description = "description",
                Id = 3,
                NutritionFacts = new NutritionFacts(),
                BaseLineNutritionFacts = new NutritionFacts()
            };
            Dish dish4 = new Dish()
            {
                Name = "TempDish4",
                Description = "description",
                Id = 4,
                NutritionFacts = new NutritionFacts(),
                BaseLineNutritionFacts = new NutritionFacts()
            };

            var dishList1 = new List<Dish>();
            dishList1.Add(dish1);
            dishList1.Add(dish2);
            var dishList2 = new List<Dish>();
            dishList2.Add(dish3);
            dishList2.Add(dish4);

            MenuPart menuPart1 = new MenuPart()
            {
                Name = "TestMenuPart",
                Id = 1,
                OrderBy = 1,
                Dishes = dishList1
            };
            MenuPart menuPart2 = new MenuPart()
            {
                Name = "TestMenuPart",
                Id = 2,
                OrderBy = 2,
                Dishes = dishList1
            };
            List<MenuPart> menuPartsList = new List<MenuPart>();
            menuPartsList.Add(menuPart1);
            menuPartsList.Add(menuPart2);
            Menu menu = new Menu();
            menu.MenuParts.Add(menuPart1);
            menu.MenuParts.Add(menuPart2);
            RestaurantBasicData restBasic = new RestaurantBasicData()
            {
                Name = "TestRest",
                Id = new ObjectId(),
                Menu = menu
            };

            RestaurantModelBackOffice restBO = new RestaurantModelBackOffice();
            var restModel = restBasic.ToRestaurantModel(true, "he", restBO);
            foreach (var menuPart in restModel.Menu.MenuParts)
            {
                foreach (DishModel dishModel in menuPart.Dishes)
                {
                    Assert.IsTrue(dishModel.GetType() == typeof(DishModelBackOffice));
                }
            }
        }
Пример #26
0
 public RestaurantTrainPattern(RestaurantBasicData restData)
 {
     if (restData.Name != null) this.Name = restData.Name;
     if (restData.Description != null) this.Description = restData.Description;
     if (restData.Cuisines != null) this.Cuisines = restData.Cuisines;
 }
Пример #27
0
        public void TestGetRestourantData_should_retun_same()
        {
            //arrange
            MongoEntityRepositoryBase<RestaurantBasicData> mongoRepository = new MongoEntityRepositoryBase<RestaurantBasicData>(m_Testdb);
            RestaurantBasicData someTestyRestaurnat = new RestaurantBasicData()
            {
                Description = "משהו בעברית וארווווווווווווך",
                //Id = Guid.NewGuid().ToString(),
                ItemLocation = new Location() { Latitude = 1.001, Longitude = 2.001 },
                MappedState = new SuspiciousState() { Index = 100 },
                Name = "מסעדת רן ודניאל",
            };

            //Act
            mongoRepository.Add(someTestyRestaurnat);

            var fetchedOne = mongoRepository.GetSingle(someTestyRestaurnat.Id);

            //Assert
            Assert.IsNotNull(fetchedOne);
            Assert.AreEqual(someTestyRestaurnat.Id, fetchedOne.Id);
        }
        public void TestUpdateDishesLocation_shouldChangeLocationOfAllDishesToRestaurantLocation()
        {
            RestaurantBasicData restaurant = new RestaurantBasicData()
            {
                //arrange
                Id = ObjectId.Parse("50ae8b2a3720e80d085376db"),
                ItemLocation = new Location() { Latitude = 32.279296, Longitude = 34.860367 },
                Menu = new Menu()
            };

            Dish dish1 = new Dish()
            {
                Id = 1,
                Description = "סלט ירקות עם חתיכות חזה עוף",
                DishState = DishStateEnum.Active,
                Name = "סלט קיסר",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 30, Longitude = 27 },
                ImageUrl = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRqKcIkvCQDkCNQkXq0TWtiqRSF5ryYK7NYB79ZBVebpjKBVPcA",
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 7.77 },
                RecipeId = 10,
                State = new SuspiciousState() { Index = 7.77 },
                OverrideIngredients = new List<Ingredient>()
            };
            Dish dish2 = new Dish()
            {
                Id = 3,
                Description = "שניצל מוגש עם צ'יפס",
                DishState = DishStateEnum.Active,
                Name = "שניצל",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 31, Longitude = 29 },
                ImageUrl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQX5WBzP336hF8Q0FQpk5TdX8m7GI7ymVqJMtyrzSA3afEkqfU8CA",
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 8.88 },
                RecipeId = 28,
                State = new SuspiciousState() { Index = 8.88 },
                OverrideIngredients = new List<Ingredient>()
            };
            Dish dish3 = new Dish()
            {
                Id = 15,
                Description = "המבורגר 220גר עם צ'יפס בצד",
                DishState = DishStateEnum.Active,
                Name = "המבורגר",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 32, Longitude = 30 },
                ImageUrl = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTmEsDLKjW9dj_Vl8SMdESJkTBGncjY5QDt0sqK77txEUwSi2RzUA",
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 50 },
                RecipeId = 169,
                State = new SuspiciousState() { Index = 50 },
                OverrideIngredients = new List<Ingredient>()
            };
                        Dish dish4 = new Dish()
            {
                Id = 4,
                Description = "חזה עך עם תוספת",
                DishState = DishStateEnum.Active,
                Name = "חזה עוף",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 32.89654, Longitude = 31.321 },
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 45.5 },
                RecipeId = 169,
                State = new SuspiciousState() { Index = 45.5 },
                OverrideIngredients = new List<Ingredient>()
            };
            MenuPart menuPart1 = new MenuPart(){Name = "עיקריות"};
            menuPart1.Dishes.Add(dish1);
            menuPart1.Dishes.Add(dish2);
            menuPart1.Dishes.Add(dish3);
            MenuPart menuPart2 = new MenuPart(){Name = "מנה ראשונה"};
            menuPart2.Dishes.Add(dish1);
            menuPart2.Dishes.Add(dish2);
            menuPart2.Dishes.Add(dish3);
            restaurant.Menu.MenuParts.Add(menuPart1);
            restaurant.Menu.MenuParts.Add(menuPart2);

            //act

            restaurant.UpdateDishesLocation();

            //assert

            int dishCount = 0;
            foreach (var part in restaurant.Menu.MenuParts)
            {
                foreach (var dish in part.Dishes)
                {
                    dishCount++;
                    Assert.AreEqual(restaurant.ItemLocation, dish.ItemLocation);
                }
            }
            //Chech if all dishes saved
            Assert.AreEqual(dishCount, 6);
        }
Пример #29
0
        private void AddRestourantToRepositary()
        {
            //arrange
            MongoEntityRepositoryBase<RestaurantBasicData> mongoRepository = new MongoEntityRepositoryBase<RestaurantBasicData>(m_Testdb);
            RestaurantBasicData someTestyRestaurnat = new RestaurantBasicData()
            {
                Description = "משהו בעברית וארווווווווווווך",
                //Id = Guid.NewGuid().ToString(),
                ItemLocation = new Location() { Latitude = 10.001, Longitude = 20.001 },
                MappedState = new SuspiciousState() { Index = 100 },
                Name = "מסעדת רן ודניאל",
            };

            mongoRepository.Add(someTestyRestaurnat);
        }
Пример #30
0
//======================================================================================================

        public DefaultMenuRestaurant ToDefaultMenuRestaurant(RestaurantBasicData rest) 
        {
            if (rest != null)
            {
                log.InfoFormat("[ToDefaultMenuRestaurant] rest.Name={0}, rest.Id={1}.", rest.Name, rest.Id.ToString());
                DefaultMenuRestaurant defaultMenuRest = new DefaultMenuRestaurant()
                {
                    Id = new ObjectId(),
                    Name = rest.Name,
                    Description = rest.Description
                };
                if (rest.Cuisine != null) defaultMenuRest.Cuisine = rest.Cuisine;
                if (rest.Cuisines != null && rest.Cuisines.Count > 0) defaultMenuRest.Cuisines = rest.Cuisines;
                if (rest.Operator != null && rest.Operator != "") defaultMenuRest.Operator = rest.Operator;
                if (rest.LocalizedName != null) defaultMenuRest.LocalizedName = rest.LocalizedName;
                if (rest.LocalizedDescription != null) defaultMenuRest.LocalizedDescription = rest.LocalizedDescription;
                if (rest.Menu != null && rest.Menu.MenuParts != null) defaultMenuRest.Menu = rest.Menu;
                if (rest.LogoUrl != null) defaultMenuRest.LogoUrl = rest.LogoUrl;
                if (rest.Image != null) defaultMenuRest.Image = rest.Image;
                if (rest.CreatedAt != null) defaultMenuRest.CreatedAt = rest.CreatedAt;
                if (rest.UpdatedAt != null) defaultMenuRest.UpdatedAt = rest.UpdatedAt;
                
                return defaultMenuRest;
            }
            else 
            {
                log.ErrorFormat("[ToDefaultMenuRestaurant] rest=null.");
                return null;
            }
        }