public ActionResult Insert(Restaurant item, HttpPostedFileBase fluResim) { if (ModelState.IsValid) { bool sonuc; string fileResult = FxFunction.ImageUpload(fluResim, FolderPath.Restaurant, out sonuc); if (sonuc) { item.imagePath = fileResult; } else { ViewBag.Mesaj = fileResult; } bool eklemeSonucu = rs.Add(item); if (eklemeSonucu) { return(RedirectToAction("Index")); } else { ViewBag.Mesaj = "Ekleme işlemi Sirasinda Bir Hata Olustu."; } } return(View()); }
public int RestaurantAdd(int cityid, string name) { RestaurantService r = new RestaurantService(); Restaurant model = new Restaurant(); model.CityID = cityid; model.Name = name; return r.Add(model, 0); }
public async Task <IActionResult> Post( [FromForm][ModelBinder(BinderType = typeof(FormDataJsonBinder))] RestaurantDTO restaurant, [FromForm] IFormFile file, [FromForm][ModelBinder(BinderType = typeof(FormDataJsonBinder))] List <Cuisine> cuisines ) { if (restaurant == null) { return(BadRequest(ModelState)); } _restaurantService.Add(restaurant, file, cuisines); await _restaurantService.SaveDataBase(); return(Ok(restaurant)); }
public IActionResult Edit(RestaurantModel model) { try { if (model.RestaurantId > 0) { _restaurantService.Edit(model); } else { _restaurantService.Add(model); } return(RedirectToAction("Index")); } catch (Exception ex) { _logger.LogError(ex, "Failed to load retaurant details"); return(RedirectToAction("Edit", model.RestaurantId)); } }