public ActionResult Edit(MenuItem item) { if (ModelState.IsValid) { try { if (item.MenuItemId <= 0) { item.AddedByUserId = User.UserID; item.DateAdded = DateTime.UtcNow; item.ModifiedByUserId = User.UserID; item.DateModified = DateTime.UtcNow; _menuDataRepository.CreateItem(item); } else { var existingItem = _menuDataRepository.GetItem(item.MenuItemId, item.ModuleId); existingItem.ModifiedByUserId = User.UserID; existingItem.DateModified = DateTime.Now; existingItem.IsDailySpecial = item.IsDailySpecial; existingItem.IsVegetarian = item.IsVegetarian; existingItem.ImageUrl = item.ImageUrl; existingItem.Price = item.Price; existingItem.Name = item.Name; existingItem.Desc = item.Desc; _menuDataRepository.UpdateItem(existingItem); } } catch (Exception ex) { Log.ErrorFormat("An error occurred in saving the menu item. Exception: {0}", ex); } return(RedirectToDefaultRoute()); } return(View(item)); }