public ActionResult Create(WatchModel watchModel, HttpPostedFileBase file) { if (ModelState.IsValid) { Watch watch = Mapper.Map<WatchModel,Watch>(watchModel); _watchService.CreateWatch(watch); var image = _imageService.ConvertFileToImageDataAndBind(file, watch); _imageService.AddImage(image); return RedirectToAction("Index"); } return View(watchModel); }
public ActionResult Edit(WatchModel watchModel, HttpPostedFileBase file) { if (ModelState.IsValid && file!=null) { Watch watch = Mapper.Map<WatchModel, Watch>(watchModel); _watchService.EditWatch(watch); _imageService.AddImage(_imageService.ConvertFileToImageDataAndBind(file, watch)); //var image = _imageService.ConvertFileToImageDataAndBind(file, watch); return RedirectToAction("Index"); } if (file == null) return RedirectToAction("Edit", "Watch", new { id = watchModel.Id }); return View(watchModel); }
public ActionResult Edit(WatchModel watchModel, HttpPostedFileBase file) { if (ModelState.IsValid && file != null) { Watch watch = Mapper.Map<WatchModel, Watch>(watchModel); _watchService.EditWatch(watch); _imageService.AddImage(_imageService.ConvertFileToImageDataAndBind(file, watch)); ViewBag.Message = "has been saved"; TempData["message"] = string.Format("{0} has been saved", watch.Name); return RedirectToAction("Index"); } //if (file == null) // return RedirectToAction("Edit", "Watch", new { id = watchModel.Id }); return View(watchModel); }