public ActionResult AddPhoto(int?id, PhotoAdd newItem) { // Validate the input // Two conditions must be checked if (!ModelState.IsValid && id.GetValueOrDefault() == newItem.PropertyId) { return(View(newItem)); } // Process the input var addedItem = m.PropertyPhotoAdd(newItem); if (addedItem == null) { return(View(newItem)); } else { return(RedirectToAction("Details", new { id = addedItem.Id })); } }