public RedirectToActionResult EditCake(Cake cake) { if (ModelState.IsValid) { string uniqueFileName = UploadedFile(cake); if (uniqueFileName != null) // if the user didn't change the photo, we won't assign a null to the photo name, we instead sent the photo name as hidden parameter, if a value is sent , the value would replace the hidden parameter { cake.CakePhoto = uniqueFileName; } var the_cake = _CakeRepository.GetCakeById(cake.CakeId); if (the_cake != null) { _CakeRepository.EditCake(the_cake, cake); } } return(RedirectToAction("Index")); }