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); } }
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(); } }
public void UpdateRestaurant(RestaurantBasicData restaurant) { log.DebugFormat("[UpdateRestaurant(RestaurantBasicData)] RestaurantBasicData={0}.", restaurant.ToString()); restaurant.UpdatedAt = DateTime.UtcNow; using (Restaurants restaurantsDb = new Restaurants()) { MongoEntityRepositoryBase<RestaurantBasicData> basicData = new MongoEntityRepositoryBase<RestaurantBasicData>(restaurantsDb.DB); basicData.Update(restaurant); } }