コード例 #1
0
        public string AddNewOperatorMap(OperatorMap map)
        {
            using (Restaurants restaurantsDb = new Restaurants())
            {
                MongoEntityRepositoryBase<OperatorMap> basicData =
                    new MongoEntityRepositoryBase<OperatorMap>(restaurantsDb.DB);

                basicData.Add(map);
                return map.Id.ToString();
            }
        }
コード例 #2
0
 /// <summary>
 /// Should find DefaultMenuRestaurant with same Operator and return it's Menu
 /// </summary>
 /// <param name="?"></param>
 /// <returns></returns>
 public Menu GetDefaulMenuByOperatorMap(OperatorMap operatorMap)
 {
     if (operatorMap != null && operatorMap.Name != null && operatorMap.Name != "")
     {
         DefaultMenuRestaurant defRest = GetDefaultRestaurantByOperatorName(operatorMap.Name);
         if (defRest != null)
         {
             int menuPartsCount = defRest.Menu != null && defRest.Menu.MenuParts != null ? defRest.Menu.MenuParts.Count : 0;
             log.InfoFormat("[GetDefaulMenuByOperatorMap] operatorMap.Name={0}, returned menu parts count={1}.", operatorMap.Name, menuPartsCount);
             return defRest.Menu;
         }
         else
         {
             log.WarnFormat("[GetDefaulMenuByOperatorMap] operatorMap.Name={0}, default menu restaurant not found.", operatorMap.Name);
         }
     }
     else
     {
         log.ErrorFormat("[GetDefaulMenuByOperatorMap] operatorMap is null or Name is null or empty.");
     }
     return null;
 }
コード例 #3
0
        public void AddNewOperatorMapsToDb()
        {
            OperatorMap BurgerRanchMap = new OperatorMap()
            {
                //Id = ObjectId.Parse(""),
                Name = "Burger Ranch",
                NamesList = new List<string>() { "Ranch", "BurgerRanch", "ראנץ'", "ראנץ", "בורגראנץ'" }
            };
            OperatorMap mcdonaldsMap = new OperatorMap()
            {
                //Id = ObjectId.Parse(""),
                Name = "McDonalds",
                NamesList = new List<string>() { "McDonalds", "McDonald's", "mc donald", "mc donald's", "מקדונלדס", "מקדונלד'ס", "מק דונלד'ס", "מקדונאלדס" }
            };
            OperatorMap dominosMap = new OperatorMap()
            {
                //Id = ObjectId.Parse(""),
                Name = "Dominos",
                NamesList = new List<string>() { "Dominos", "Domino's", "domino's", "דומינוס", "דומינו", "דומינו'ס", "דומינו'ס" }
            };
            OperatorMap BlackBarBurgerMap = new OperatorMap()
            {
                //Id = ObjectId.Parse(""),
                Name = "Black Bar n Burger",
                NamesList = new List<string>() { "Black", "בלאק", "Black 'n'", "BlackBarBurger" }
            };
            OperatorMap AromaMap = new OperatorMap()
            {
                //Id = ObjectId.Parse(""),
                Name = "Aroma",
                NamesList = new List<string>() { "Aroma", "ארומה" }
            };
            OperatorMap KingGeorgeMap = new OperatorMap()
            {
                //Id = ObjectId.Parse(""),
                Name = "King George",
                NamesList = new List<string>() { "George", "Gorg", "ג'ורג" }
            };
            OperatorMap SpagetimMap = new OperatorMap()
            {
                //Id = ObjectId.Parse(""),
                Name = "Spagetim",
                NamesList = new List<string>() { "Spagetim", "ספגטים"}
            };

            // Act
            string BurgerRanchMapId = operatorServices.UpdateOrCreateOperatorMap(BurgerRanchMap);
            string McDonaldsId = operatorServices.UpdateOrCreateOperatorMap(mcdonaldsMap);
            string DominosMapId = operatorServices.UpdateOrCreateOperatorMap(dominosMap);
            string BlackBarBurgerMapId = operatorServices.UpdateOrCreateOperatorMap(BlackBarBurgerMap);
            string AromaMapId = operatorServices.UpdateOrCreateOperatorMap(AromaMap);
            string KingGeorgeMapId = operatorServices.UpdateOrCreateOperatorMap(KingGeorgeMap);
            string SpagetimMapId = operatorServices.UpdateOrCreateOperatorMap(SpagetimMap);

            //// Assert
            Assert.IsNotNull(BurgerRanchMapId);
            Assert.IsNotNull(McDonaldsId);
            Assert.IsNotNull(DominosMapId);
            Assert.IsNotNull(AromaMapId);
            Assert.IsNotNull(BlackBarBurgerMapId);

            Assert.AreEqual(BurgerRanchMap.Id.ToString(), BurgerRanchMapId);
            Assert.AreEqual(mcdonaldsMap.Id.ToString(), McDonaldsId);
            Assert.AreEqual(dominosMap.Id.ToString(), DominosMapId);
            Assert.AreEqual(BlackBarBurgerMap.Id.ToString(), BlackBarBurgerMapId);
            Assert.AreEqual(AromaMap.Id.ToString(), AromaMapId);
            Assert.AreEqual(KingGeorgeMap.Id.ToString(), KingGeorgeMapId);
            Assert.AreEqual(SpagetimMap.Id.ToString(), SpagetimMapId);
        }
コード例 #4
0
 /// <summary>
 /// If exists update, if not create new
 /// </summary>
 /// <param name="OperatorMap"></param>
 public string UpdateOrCreateOperatorMap(OperatorMap OperatorMap)
 {
     log.InfoFormat("[UpdateOrCreateOperatorMap] OperatorMap.Name={0}.", OperatorMap.Name);
     var OperatorMapDB = GetOperatorMapByName(OperatorMap.Name);
     if (OperatorMapDB != null)
     {
         if (OperatorMap.Id != OperatorMapDB.Id) OperatorMap.Id = OperatorMapDB.Id;
         UpdateOperatorMap(OperatorMap);
         return OperatorMap.Id.ToString();
     }
     else
     {
         return AddNewOperatorMap(OperatorMap);
     }
 }
コード例 #5
0
 public void UpdateOperatorMap(OperatorMap map)
 {
     log.InfoFormat("[UpdateOperatorMap] OperatorMap={0}.", map.Name);
     using (Restaurants restaurantsDb = new Restaurants())
     {
         MongoEntityRepositoryBase<OperatorMap> basicData =
                       new MongoEntityRepositoryBase<OperatorMap>(restaurantsDb.DB);
         basicData.Update(map);
     }
 }