public int Insert(NotificationModal notification) { int rowsAffected = 0; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); SqlCommand com = new SqlCommand("spInsertNotification", connection); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@SessionId", notification.SessionId); com.Parameters.AddWithValue("@SemesterId", notification.SemesterId); com.Parameters.AddWithValue("@CourseId", notification.CourseId); com.Parameters.AddWithValue("@TeacherId", notification.TeacherId); com.Parameters.AddWithValue("@NotificationName", notification.NotificationName); com.Parameters.AddWithValue("@NotificationDescription", notification.NotificationDescription); try { rowsAffected = com.ExecuteNonQuery(); } catch (Exception excp) { return(0); } return(rowsAffected); } }
public JsonResult Insert(NotificationModal notification) { return(Json(_databaseConnection.Insert(notification), JsonRequestBehavior.AllowGet)); }