public static string Download(MongoEntityRepositoryBase<RecipeBasicData> mongoRepository, int recipeIndex) { string recipeId = recipeIdPrefix + recipeIndex; RecipeBasicData existingRecipe = mongoRepository.GetSingle(recipeId); if (existingRecipe != null) return recipeId; string url = string.Format(absUrlTemplate, recipeIndex); StringBuilder output = new StringBuilder(); HtmlWeb webGet = new HtmlWeb(); webGet.UserAgent = "Wget/1.4.0"; HtmlDocument htmlDoc = webGet.Load(url); //webGet.StatusCode == System.Net.HttpStatusCode.OK log.InfoFormat("Fetching html at {0}...", url); string html = htmlDoc.DocumentNode.InnerHtml; RecipeBasicData recipe = new RecipeBasicData() { Id = recipeId, SourceUrl = url, RawHtmlResponse = html, RippedAt = DateTime.UtcNow }; mongoRepository.Add(recipe); return recipeId; }
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(); } }
//===================================================================================== public string AddNewDefaultMenuRestaurant(DefaultMenuRestaurant rest) { using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<DefaultMenuRestaurant> basicData = new MongoEntityRepositoryBase<DefaultMenuRestaurant>(restaurantsDb.DB); basicData.Add(rest); return rest.Id.ToString(); } }
public static string AddUserMealProfileToDB(UserMealProfile userMealProfile) { log.DebugFormat("[AddUserMealProfileToDB] restaurant={0}.", userMealProfile.ToString()); using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<UserMealProfile> basicData = new MongoEntityRepositoryBase<UserMealProfile>(restaurantsDb.DB); userMealProfile.CreatedAt = DateTime.UtcNow; basicData.Add(userMealProfile); return userMealProfile.Id.ToString(); } }
public void AddAndGetTest() { MongoEntityRepositoryBase<RecipeBasicData> mongoRepository = new MongoEntityRepositoryBase<RecipeBasicData>(m_Testdb); //arrange RecipeBasicData entity = new RecipeBasicData() { Id = "RecipeId", Name = "RecipeName", Description = "Description", Directions = "Directions", Ingredients = new List<Ingredient>(), //Images = Image Object, Author = "Author", SourceUrl = "SourceUrl", RawHtmlResponse = "RawHtmlResponse", Labels = new List<string> { "Label1", "Label 2" }, RippedAt = DateTime.UtcNow }; entity.Ingredients.Add(new Ingredient() { Name = "Ingredient 1", Amount = new IncredientAmount() { Amount = 3.0 / 2 } } ); entity.Ingredients.Add(new Ingredient() { Name = "Ingredient 2", Amount = new IncredientAmount() { Amount = 2 } } ); //act mongoRepository.Add(entity); RecipeBasicData fetchedEntity = mongoRepository.GetSingle(entity.Id); //assert Assert.IsNotNull(fetchedEntity); Assert.AreEqual(fetchedEntity.Id, entity.Id); Assert.AreEqual(fetchedEntity.Name, entity.Name); Assert.AreEqual(fetchedEntity.Description, entity.Description); Assert.AreEqual(fetchedEntity.Directions, entity.Directions); Assert.AreEqual(fetchedEntity.Ingredients.First().Name, entity.Ingredients.First().Name); Assert.AreEqual(fetchedEntity.Ingredients.Last().Name, entity.Ingredients.Last().Name); Assert.AreEqual(fetchedEntity.Images, entity.Images); Assert.AreEqual(fetchedEntity.Author, entity.Author); Assert.AreEqual(fetchedEntity.SourceUrl, entity.SourceUrl); Assert.AreEqual(fetchedEntity.RawHtmlResponse, entity.RawHtmlResponse); Assert.AreEqual(fetchedEntity.Labels.First(), entity.Labels.First()); Assert.AreEqual(fetchedEntity.Labels.Last(), entity.Labels.Last()); Assert.AreEqual(fetchedEntity.Ingredients.First().Amount.Amount, entity.Ingredients.First().Amount.Amount); Assert.AreEqual(fetchedEntity.Ingredients.Last().Name, entity.Ingredients.Last().Name); }
public List<LoadDBStatus> DoLoad() { MongoEntityRepositoryBase<ProductBasicData> mongoRepository = new MongoEntityRepositoryBase<ProductBasicData>(m_db); List<LoadDBStatus> returnValue = new List<LoadDBStatus>(); log.Info("[DoLoad] started."); foreach (var file in m_filesForLoadingToDB) { LoadDBStatus loadStat = new LoadDBStatus(); loadStat.File = file; try { string html = File.ReadAllText(file); ProductBasicDataFetcher fetcher = new ProductBasicDataFetcher(html); var products = fetcher.FetchProducts(); foreach (var item in products) { item.Category = file; var producExistInDB = mongoRepository.GetSingle(item.Barcode); if (producExistInDB == null) { log.DebugFormat("Inserts new product to DB ={0}.", item); mongoRepository.Add(item); } else { log.DebugFormat("Updates {0}.", item); mongoRepository.Update(item); } } } catch (Exception ex) { log.ErrorFormat("[DoLoad] Problem on loading file={0}, exception={1}.", file, ex); loadStat.ErrorException = ex; } returnValue.Add(loadStat); } return returnValue; }
public string AddRestToImportedDB(RestaurantOsm rest) { try { log.InfoFormat("[AddRestToImportedDB] rest.Name={0}, rest.Name={0}, rest.NodeReference.id={1}.", rest.Name, rest.NodeReference.id); rest.CreatedAt = DateTime.UtcNow; //using (ImportedRestaurants restaurantsDb = new ImportedRestaurants()) using (FinlandSwedenOSMRestaurants restaurantsDb = new FinlandSwedenOSMRestaurants()) { MongoEntityRepositoryBase<RestaurantOsm> basicData = new MongoEntityRepositoryBase<RestaurantOsm>(restaurantsDb.DB); basicData.Add(rest); return rest.Id.ToString(); } } catch (Exception e) { log.ErrorFormat("[AddRestToImportedDB] Exception={0}.", e); return null; } }
public string AddRestaurantsCompareListToImportedDB(RestaurantsCompareList compareList) { try { compareList.CompareDate = DateTime.UtcNow; log.InfoFormat("[AddRestaurantsCompareListToImportedDB] compareList.CompareDate={0}, compareList.CompareSource={1}, compareList.Count={2}, compareList.Id={3}.", compareList.CompareDate, compareList.CompareSource, compareList.CompareList.Count, compareList.Id.ToString()); //using (ImportedRestaurants restaurantsDb = new ImportedRestaurants()) using (FinlandSwedenOSMRestaurants restaurantsDb = new FinlandSwedenOSMRestaurants()) { MongoEntityRepositoryBase<RestaurantsCompareList> basicData = new MongoEntityRepositoryBase<RestaurantsCompareList>(restaurantsDb.DB); basicData.Add(compareList); return compareList.Id.ToString(); } } catch (Exception e) { log.ErrorFormat("[AddRestaurantsCompareListToImportedDB] Exception={0}.", e); return null; } }
public void AddAndGetTest() { MongoEntityRepositoryBase<ProductBasicData> mongoRepository = new MongoEntityRepositoryBase<ProductBasicData>(m_Testdb); //arrange ProductBasicData entity = new ProductBasicData() { ProductId = "1111", EffectivePrice = "10", Barcode = "121211", Description = "SomeDescription", ExtendedData = new ProductExtendedData(), //Image = "urlToImage", ImageSource = "http:\\someDomain.dan", inb = "inb", iq = "iq", pbcatid = "pbcatid", ProductName = "productName", qty = "2" }; //act mongoRepository.Add(entity); var fetchedEntity = mongoRepository.GetSingle(entity.Barcode); //assert Assert.IsNotNull(fetchedEntity); Assert.AreEqual(fetchedEntity.Barcode, entity.Barcode); Assert.AreEqual(fetchedEntity.Description, entity.Description); Assert.AreEqual(fetchedEntity.EffectivePrice, entity.EffectivePrice); Assert.AreEqual(fetchedEntity.Image, entity.Image); Assert.AreEqual(fetchedEntity.ImageSource, entity.ImageSource); Assert.AreEqual(fetchedEntity.inb, entity.inb); Assert.AreEqual(fetchedEntity.iq, entity.iq); Assert.AreEqual(fetchedEntity.pbcatid, entity.pbcatid); Assert.AreEqual(fetchedEntity.ProductId, entity.ProductId); Assert.AreEqual(fetchedEntity.ProductName, entity.ProductName); Assert.AreEqual(fetchedEntity.qty, entity.qty); }
public string AddGeneralDishToDB(GeneralDish generalDish) { try { string ndbNo = (generalDish.Dish.OverrideIngredients != null && generalDish.Dish.OverrideIngredients[0].USDA_NDB_No != null) ? generalDish.Dish.OverrideIngredients[0].USDA_NDB_No.ToString() : "No USDA_NDB_No"; log.InfoFormat("[AddGeneralDishToDB] generalDish.Dish.Name={0}, ingredient.USDA_NDB_No={1}.", generalDish.Dish.Name, ndbNo); if (generalDish != null) { using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<GeneralDish> basicData = new MongoEntityRepositoryBase<GeneralDish>(restaurantsDb.DB); basicData.Add(generalDish); } return generalDish.Id.ToString(); } return null; } catch (Exception e) { log.ErrorFormat("[AddGeneralDishToDB] Exception={0}.", e); return null; } }
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 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 string AddRestaurantToDB(RestaurantModel restaurantmodel) { log.DebugFormat("[AddRestaurantToDB] restaurantmodel={0}.", restaurantmodel.ToString()); using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<RestaurantBasicData> basicData = new MongoEntityRepositoryBase<RestaurantBasicData>(restaurantsDb.DB); RestaurantBasicData tempRest = new RestaurantBasicData() { //Id = ObjectId.Parse(restaurantmodel.Id), Name = restaurantmodel.Name, Description = restaurantmodel.Description, LogoUrl = (restaurantmodel.LogoUrl != null) ? restaurantmodel.LogoUrl : "", Menu = restaurantmodel.Menu.ToMenuBasicModel(), Adress = restaurantmodel.Adress, ItemLocation = (restaurantmodel.Location != null) ? restaurantmodel.Location.toLoaction() : null, Phone = restaurantmodel.Phone, CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow }; basicData.Add(tempRest); SaveUserActivity(new AddRestaurantActivity() { RestaurantID = tempRest.Id.ToString(), Location = tempRest.ItemLocation }); return tempRest.Id.ToString(); } }
public void AddGeneralDishToDBTest_ShouldSaveDishInDBAndUpdateMongoIdProperty() { GeneralDish generalDish = new GeneralDish() { Dish = new Dish() }; using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<GeneralDish> basicData = new MongoEntityRepositoryBase<GeneralDish>(restaurantsDb.DB); basicData.Add(generalDish); Object savedId = generalDish.Id; basicData.Delete(savedId); } Assert.IsNotNull(generalDish.Id); }
public void AddListOfCouponToDB_ShouldCreateNewListCouponAndSaveInDB() { //Arrange using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<CouponType> basicData = new MongoEntityRepositoryBase<CouponType>(restaurantsDb.DB); CouponType tempCoupon1 = new CouponType() { Description = "קפה + מאפה ב15% הנחה במסעדת Nelly's Kitchen. למימוש יש להראות את המסך במסעדה. לפרטי המסעדה לחץ על המדליה", ValidFrom = new DateTime(0), ValidUntil = DateTime.UtcNow.AddHours(1), RestaurantsIDs = new List<string>() { "11111" } }; CouponType tempCoupon2 = new CouponType() { Description = "מנה ראשונה במתנה בהזמנת עיקרית במסעדת BG99. למימוש יש להראות את המסך במסעדה. לפרטי המסעדה לחץ על המדליה", ValidFrom = new DateTime(0), ValidUntil = DateTime.UtcNow.AddHours(1), RestaurantsIDs = new List<string>() { "22222" } }; CouponType tempCoupon3 = new CouponType() { Description = "קפה + מאפה ב15% הנחה במסעדתאכול כפי יכולתך רק ב89 שקל במסעדת קולומבוס", ValidFrom = new DateTime(0), ValidUntil = DateTime.UtcNow.AddHours(1), RestaurantsIDs = new List<string>() { "33333" } }; //Act //save tempCoupon in DB basicData.Add(tempCoupon1); basicData.Add(tempCoupon2); basicData.Add(tempCoupon3); //fetch coupon fromDB string savedCouponId1 = tempCoupon1.Id.ToString(); string savedCouponId2 = tempCoupon2.Id.ToString(); string savedCouponId3 = tempCoupon3.Id.ToString(); CouponType fetchedCoupon1 = basicData.GetSingle(ObjectId.Parse(savedCouponId1)); CouponType fetchedCoupon2 = basicData.GetSingle(ObjectId.Parse(savedCouponId2)); CouponType fetchedCoupon3 = basicData.GetSingle(ObjectId.Parse(savedCouponId3)); serviceLayer.DeleteCoupon(savedCouponId1); serviceLayer.DeleteCoupon(savedCouponId2); serviceLayer.DeleteCoupon(savedCouponId3); //Assert Assert.IsNotNull(fetchedCoupon1); Assert.AreEqual(tempCoupon1.Id, fetchedCoupon1.Id); Assert.AreEqual(tempCoupon1.Description, fetchedCoupon1.Description); Assert.AreEqual(tempCoupon1.ValidFrom, fetchedCoupon1.ValidFrom); Assert.AreEqual(tempCoupon1.ValidUntil.Millisecond, fetchedCoupon1.ValidUntil.Millisecond); Assert.IsNotNull(fetchedCoupon2); Assert.AreEqual(tempCoupon2.Id, fetchedCoupon2.Id); Assert.AreEqual(tempCoupon2.Description, fetchedCoupon2.Description); Assert.AreEqual(tempCoupon2.ValidFrom, fetchedCoupon2.ValidFrom); Assert.AreEqual(tempCoupon2.ValidUntil.Millisecond, fetchedCoupon2.ValidUntil.Millisecond); Assert.IsNotNull(fetchedCoupon3); Assert.AreEqual(tempCoupon3.Id, fetchedCoupon3.Id); Assert.AreEqual(tempCoupon3.Description, fetchedCoupon3.Description); Assert.AreEqual(tempCoupon3.ValidFrom, fetchedCoupon3.ValidFrom); Assert.AreEqual(tempCoupon3.ValidUntil.Millisecond, fetchedCoupon3.ValidUntil.Millisecond); } }
public void SaveFoodTable() { log.InfoFormat("[SaveFoodTable]."); try { using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<Ingredient> basicData = new MongoEntityRepositoryBase<Ingredient>(restaurantsDb.DB); using (usda_nutritionEntities context = new usda_nutritionEntities()) { var food_groups = context.FD_GROUP.ToList(); var weigts = context.WEIGHT.ToList(); var foods = context.FOOD_DES.ToList(); foreach (var item in foods) { Spontaneous.DataModel.Ingredient ingredient = FoodDesToIngredient(item, food_groups); if(ingredient != null) basicData.Add(ingredient); } Console.Write("After Food copy loop.\n"); } } } catch (Exception e) { log.ErrorFormat("[SaveFoodTable] Exception={0}.", e); } }
public void AddNewCoupon_ShouldCreateNewCouponAndSaveInDB() { //Arrange using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<CouponType> basicData = new MongoEntityRepositoryBase<CouponType>(restaurantsDb.DB); CouponType tempCoupon = new CouponType() { Description = "קפה + מאפה ב15% הנחה במסעדת Nelly's Kitchen. למימוש יש להראות את המסך במסעדה. לפרטי המסעדה לחץ על המדליה", ValidFrom = new DateTime(0), ValidUntil = DateTime.UtcNow.AddHours(1), RestaurantsIDs = new List<string>() { "52810aca3720e808eccf5149" } }; //Act //save tempCoupon in DB basicData.Add(tempCoupon); //restor coupon fromDB string savedCouponId = tempCoupon.Id.ToString(); CouponType fetchedCoupon = basicData.GetSingle(ObjectId.Parse(savedCouponId)); serviceLayer.DeleteCoupon(savedCouponId); //Assert Assert.IsNotNull(fetchedCoupon); Assert.AreEqual(tempCoupon.Id, fetchedCoupon.Id); Assert.AreEqual(tempCoupon.Description, fetchedCoupon.Description); Assert.AreEqual(tempCoupon.ValidFrom, fetchedCoupon.ValidFrom); Assert.AreEqual(tempCoupon.ValidUntil.Millisecond, fetchedCoupon.ValidUntil.Millisecond); } }
public string AddRestaurantToDB(RestaurantModel restaurantmodel) { log.DebugFormat("[AddRestaurantToDB] restaurantmodel={0}.", restaurantmodel.ToString()); using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<RestaurantBasicData> basicData = new MongoEntityRepositoryBase<RestaurantBasicData>(restaurantsDb.DB); RestaurantBasicData tempRest = new RestaurantBasicData() { //Id = ObjectId.Parse(restaurantmodel.Id), Name = restaurantmodel.Name, Description = restaurantmodel.Description, LogoUrl = (restaurantmodel.LogoUrl != null) ? restaurantmodel.LogoUrl : "", Menu = restaurantmodel.Menu.ToMenuBasicModel(), Adress = restaurantmodel.Adress, ItemLocation = (restaurantmodel.Location != null) ? restaurantmodel.Location.toLoaction() : null, Phone = restaurantmodel.Phone, CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow }; basicData.Add(tempRest); if (tempRest.LogoUrl != "" && tempRest.Image == null) { ImageServices m_imageService = new ImageServices(); m_imageService.UploadImageToRestaurant(tempRest, tempRest.LogoUrl); } if (m_userProfile.AppName != ApplicationName.BackOffice) { SaveUserActivity(new AddRestaurantActivity() { RestaurantID = tempRest.Id.ToString(), LocationAdd = tempRest.ItemLocation, ActivityLocation = tempRest.ItemLocation }); } return tempRest.Id.ToString(); } }
public void SaveNutritionsTable() { log.InfoFormat("[SaveNutritionsTable]"); using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<NutritionType> basicData = new MongoEntityRepositoryBase<NutritionType>(restaurantsDb.DB); using (usda_nutritionEntities context = new usda_nutritionEntities()) { var nutrtition = context.NUTR_DEF.ToList(); List<NutritionType> nutList = new List<NutritionType>(); foreach (var item in nutrtition) { log.InfoFormat("[SaveNutritionsTable] Loop: Nutr_No={0}, NutrDesc={1}.", item.Nutr_No, item.NutrDesc); Spontaneous.DataModel.Foods.NutritionType tempNutrition = new Spontaneous.DataModel.Foods.NutritionType() { USDA_Nutr_No = int.Parse(item.Nutr_No), Units = item.Units, Tagname = item.Tagname != null ? item.Tagname : "", NutrDesc = item.NutrDesc, Num_Dec = item.Num_Dec //SR_Order = int.Parse(item.SR_Order.ToString()), }; nutList.Add(tempNutrition); basicData.Add(tempNutrition); } Console.Write("After NutritionType copy loop.\n"); } } }
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); }
public string AddCouponToDB(CouponType coupon) { using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<CouponType> basicData = new MongoEntityRepositoryBase<CouponType>(restaurantsDb.DB); basicData.Add(coupon); log.InfoFormat("[AddCouponToDB] coupon description={0}.", coupon.Description); return coupon.Id.ToString(); } }
public void ExtendedData_PropertyTest() { //arrange var extendedData = new ProductExtendedData(); extendedData.AlergensWarnings = "AlergensWarnings"; List<Nutrition> nutr = new List<Nutrition>(); nutr.Add(new Nutrition() { Name = "Calcium", Value = "Calcium" }); nutr.Add(new Nutrition() { Name = "Carbohydrate", Value = "carb" }); //extendedData.Calcium = "Calcium"; //extendedData.Carbohydrate = "carb"; MongoEntityRepositoryBase<ProductBasicData> mongoRepository = new MongoEntityRepositoryBase<ProductBasicData>(m_Testdb); ProductBasicData entity = new ProductBasicData() { ProductId = "1111", EffectivePrice = "10", Barcode = "121211", Description = "SomeDescription", ExtendedData = extendedData, //Image = "urlToImage", ImageSource = "http:\\someDomain.dan", inb = "inb", iq = "iq", pbcatid = "pbcatid", ProductName = "productName", qty = "2" }; mongoRepository.Add(entity); //act var fetchedEntity = mongoRepository.GetSingle(entity.Barcode); var fetchedExtendedData = fetchedEntity.ExtendedData; //assert Assert.IsNotNull(fetchedExtendedData); Assert.AreEqual(fetchedExtendedData.AlergensWarnings, extendedData.AlergensWarnings); Assert.AreEqual(fetchedExtendedData.NutritionTable.First(c=> c.Name == "Calcium").Value , extendedData.NutritionTable.First(c=> c.Name == "Calcium").Value); Assert.AreEqual(fetchedExtendedData.NutritionTable.First(c => c.Name == "Carbohydrate").Value, extendedData.NutritionTable.First(c => c.Name == "Carbohydrate").Value); }
public string AddRestaurantBasicToDB(RestaurantBasicData restaurant) { log.DebugFormat("[AddRestaurantBasicToDB] restaurant={0}.", restaurant.ToString()); using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<RestaurantBasicData> basicData = new MongoEntityRepositoryBase<RestaurantBasicData>(restaurantsDb.DB); restaurant.CreatedAt = DateTime.UtcNow; restaurant.UpdatedAt = DateTime.UtcNow; basicData.Add(restaurant); if (restaurant.LogoUrl != "" && restaurant.Image == null) { ImageServices m_imageService = new ImageServices(); m_imageService.UploadImageToRestaurant(restaurant, restaurant.LogoUrl); } if (m_userProfile.AppName != ApplicationName.BackOffice) { SaveUserActivity(new AddRestaurantActivity() { RestaurantID = restaurant.Id.ToString(), LocationAdd = restaurant.ItemLocation, ActivityLocation = restaurant.ItemLocation }); } return restaurant.Id.ToString(); } }