public IActionResult ConfirmDeleteFoodItemExtra(int id) { var delFoodItemExtra = NHibernateHelperCore.GetSingleOrDefault <FoodItemExtra>(a => a.Id == id); var foodItemExtraVM = new FoodItemExtraVM() { Name = delFoodItemExtra.Name, Id = delFoodItemExtra.Id, Price = delFoodItemExtra.Price, FoodCategoryId = delFoodItemExtra.FoodCategory.Id }; return(View(foodItemExtraVM)); }
public IActionResult CreateOrUpdateFoodItemExtra(FoodItemExtraVM foodItemExtraVm) { var foodCategory = NHibernateHelperCore.GetSingleOrDefault <FoodCategory>(a => a.Id == foodItemExtraVm.FoodCategoryId); var foodItemExtra = NHibernateHelperCore.GetSingleOrDefault <FoodItemExtra>(a => a.Id == foodItemExtraVm.Id) ?? new FoodItemExtra() { Name = foodItemExtraVm.Name, Id = foodItemExtraVm.Id, Price = foodItemExtraVm.Price, FoodCategory = foodCategory }; foodItemExtra.Name = foodItemExtraVm.Name; foodItemExtra.Price = foodItemExtraVm.Price; NHibernateHelperCore.SaveOrUpdate(foodItemExtra); return(RedirectToAction("Index", "FoodItemExtra", new { id = foodItemExtraVm.FoodCategoryId })); }