public int UpdateHobby(UpdateHobby updateHobby) { ObjectParameter result = new ObjectParameter("Result", typeof(int)); using (TestingSample1Entities dataContext = new TestingSample1Entities()) { dataContext.HobbyUpdate(updateHobby.HobbyId, updateHobby.HobbyName, result); } return(Convert.ToInt32(result.Value)); }
public ActionResult Edit(UpdateHobby updateHobby) { int result = 0; try { result = iHobby.UpdateHobby(updateHobby); } catch { result = -1; } return(Json(result)); }
// GET: Hobby/Edit/5 public ActionResult Edit(int id) { UpdateHobby updateHobby = new UpdateHobby(); try { Hobby hobby = new Hobby(); hobby.HobbyId = id; var hobbyDetail = iHobby.GetHobby(hobby).FirstOrDefault(); if (hobbyDetail != null) { updateHobby.HobbyId = Convert.ToInt32(hobbyDetail.HobbyId); updateHobby.HobbyName = hobbyDetail.HobbyName; } } catch (Exception) { } return(View(updateHobby)); }