public int Update(BlogsDBModel _dbModel) { SqlConnection conn = new SqlConnection(DBConnection.GetConnection()); conn.Open(); SqlCommand dCmd = new SqlCommand("SP_SET_TBL_BLOG", conn); dCmd.CommandType = CommandType.StoredProcedure; try { dCmd.Parameters.AddWithValue("@id", _dbModel.id); dCmd.Parameters.AddWithValue("@title", _dbModel.title); dCmd.Parameters.AddWithValue("@description", _dbModel.description); dCmd.Parameters.AddWithValue("@QryOption", 2); return(dCmd.ExecuteNonQuery()); } catch (Exception ex) { //UtilityOptions.ErrorLog(ex.ToString(), MethodBase.GetCurrentMethod().Name); throw ex; } finally { dCmd.Dispose(); conn.Close(); conn.Dispose(); } }
public JsonResult LoadSelectedBlog(BlogsDBModel _dbModel) { objList = new BlogList(); List <BlogsDBModel> _dbModelList = new List <BlogsDBModel>(); _dbModelList = objList.LoadSelectedBlog(_dbModel); return(this.Json(_dbModelList, JsonRequestBehavior.AllowGet)); }
public JsonResult Update(BlogsDBModel _dbModel) { int _result = 0; objList = new BlogList(); _result = objList.Update(_dbModel); if (_result > 0) { return(Json(new { success = true })); } else { return(Json(new { success = false })); } }
public List <BlogsDBModel> LoadSelectedBlog(BlogsDBModel _dbModel) { List <BlogsDBModel> _modelList = new List <BlogsDBModel>(); SqlConnection conn = new SqlConnection(DBConnection.GetConnection()); conn.Open(); SqlCommand dAd = new SqlCommand("SP_SET_TBL_BLOG", conn); SqlDataAdapter sda = new SqlDataAdapter(dAd); dAd.CommandType = CommandType.StoredProcedure; dAd.Parameters.AddWithValue("id", _dbModel.id); dAd.Parameters.AddWithValue("@QryOption", 4); DataTable dt = new DataTable(); try { sda.Fill(dt); if (dt.Rows.Count > 0) { _modelList = (from DataRow row in dt.Rows select new BlogsDBModel { id = Convert.ToInt32(row["id"].ToString()), title = row["title"].ToString(), description = row["description"].ToString(), AddedBy = row["AddedBy"].ToString(), DateAdded = row["DateAdded"].ToString(), }).ToList(); } return(_modelList); } catch (Exception ex) { //UtilityOptions.ErrorLog(ex.ToString(), MethodBase.GetCurrentMethod().Name); throw ex; } finally { dt.Dispose(); dAd.Dispose(); conn.Close(); conn.Dispose(); } }