public ActionResult EditCuisine(Cuisine cuisine)
        {
            if (ModelState.IsValid)
            {
                if (cuisine.ImageFile != null)
                {
                    //Add image logic
                    string fileName  = Path.GetFileNameWithoutExtension(cuisine.ImageFile.FileName);
                    string extension = Path.GetExtension(cuisine.ImageFile.FileName);

                    //add date time now to make unique names always
                    fileName = DateTime.Now.ToString("yymmssfff") + extension;

                    cuisine.ImagePath = "~/Images/" + fileName;
                    fileName          = Path.Combine(Server.MapPath("~/Images/"), fileName);

                    //save in folder images
                    cuisine.ImageFile.SaveAs(fileName);
                }

                _cuisineService.UpdateCuisine(cuisine);
                ModelState.Clear();
                return(RedirectToAction("DetailsCuisine", new { id = cuisine.CuisineId }));
            }
            return(View("Error"));
        }
Exemplo n.º 2
0
 public void UpdateCuisine(Cuisine cuisine)
 {
     _cuisineService.UpdateCuisine(cuisine);
 }