public ActionResult EditWatch([Bind(Include = "WatchId, WatchCode, WatchDescription, Quantity, Price, " + "MovementID, ModelID, BandMaterial, CaseMaterial, " + "CaseRadius, Discount, Guarantee, PublishedBy, PublishedTime")] Watch watch, HttpPostedFileBase thumbnail) { if (ModelState.IsValid) { watch.WaterResistant = Request["water"] == "yes"; watch.LEDLight = Request["led"] == "yes"; watch.Alarm = Request["alarm"] == "yes"; watch.Status = Request["status"] == "yes"; watch.WatchCode = watch.WatchCode.ToUpper(); bool duplicateCode = watchService.IsDuplicatedWatchCode(watch.WatchCode, watch.WatchID); bool validImage = true; if (thumbnail != null) { validImage = FileTypeDetector.IsImageFile(thumbnail); ; } if (duplicateCode || !validImage) { var movement = movementService.GetMovementList(); var watchModel = watchModelService.GetModelsList(); ManageWatchDetailViewModel viewModel = watchService.PrepopulateEditValue(watch, movement, watchModel); if (duplicateCode) { viewModel.DuplicateErrorMessage = "Watch with code '" + watch.WatchCode + "' already existed. Please choose another one"; } if (!validImage) { viewModel.InvalidImageFileMessage = "Invalid Thumbnail. Upload file is not image"; } return(View("~/Views/Admin/admin_manage_watch_detail.cshtml", viewModel)); } String oldValue = watchService.SerializeOldValue(watch.WatchID); //thumbnail.InputStream.Position = 0; if (watchService.UpdateWatchInfo(watch, thumbnail)) { //save old value to modification table String userId = Session.GetCurrentUserInfo("Username"); if (modificationService.CreateNewModificationHistory(watch.WatchID, oldValue, userId)) { TempData["SHOW_MODAL"] = @"<script>$('#successModal').modal();</script>"; return(RedirectToAction("ViewWatch", "Admin")); } } return(Content("Unexpected Error")); //change to 404 } return(RedirectToAction("NotFound", "Home")); }