private Dictionary <string, object> prepareCategoryParameters(clsCategory prCategory) { Dictionary <string, object> par = new Dictionary <string, object>(3); par.Add("CategoryName", prCategory.CategoryName); par.Add("Description", prCategory.Description); return(par); }
public string PostCategory(clsCategory prCategory) { // insert try { int lcRecCount = clsDBConnection.Execute( "Insert Into tblCategory(CategoryName,Description) Values(@CategoryName, @Description)", prepareCategoryParameters(prCategory)); if (lcRecCount == 1) { return("One category inserted"); } else { return("Unexpected category insert count: " + lcRecCount); } } catch (Exception ex) { return(ex.GetBaseException().Message); } }
public string PutCategory(clsCategory prCategory) { // update try { int lcRecCount = clsDBConnection.Execute( "UPDATE tblCategory SET Description = @Description, WHERE CategoryName = @CategoryName", prepareCategoryParameters(prCategory)); if (lcRecCount == 1) { return("One Category updated"); } else { return("Unexpected Category update count: " + lcRecCount); } } catch (Exception ex) { return(ex.GetBaseException().Message); } }