private string UpdateFile(IFormFile file) { string pathToFile = PathToFolder + file.FileName; if (_fileOnServer.Exists(pathToFile)) { _fileOnServer.Remove(pathToFile); } pathToFile = _fileOnServer.Add(PathToFolder, file); return(pathToFile); }
public void Add(RestaurantDTO modelDTO, IFormFile file, List <Cuisine> cuisines) { var model = MapModel(modelDTO); if (file != null) { _fileOnServer.Remove(model.PathToImage); model.PathToImage = _fileOnServer.Add(PathToFolder, file); } if (cuisines != null) { var restaurantCuisineService = new BindRestaurantWithCuisine(model, cuisines); var listRestaurantCuisine = restaurantCuisineService.Add(); Db.RestaurantCuisines.AddRange(listRestaurantCuisine); } Db.Restaurants.Update(model); }