public void AddCat(Cat cat, string changes) { var conn = new SqlConnection(GetConnectionString()); var sql = "INSERT INTO " + _table + " VALUES('" + cat.GetBreed().Trim() + "','" + cat.GetCountry().Trim() + "','" + cat.GetOrigin().Trim() + "','" + cat.GetBodyType().Trim() + "','" + cat.GetCoat().Trim() + "','" + cat.GetPattern().Trim() + "','" + cat.GetImage().Trim() + "','" + cat.GetInfo().Trim(); if (_admin) { sql += "','" + changes; } sql += "')"; try { conn.Open(); var cmd = new SqlCommand(sql, conn); cmd.ExecuteNonQuery(); } catch (SqlException ex) { var msg = "AddCat Sql Error: "; msg += ex.Message; throw new Exception(msg); } finally { conn.Close(); } }
public Boolean AddCat(Cat cat, string changes) { var catBl = new CatBL(_admin); if (!_admin && catBl.IsCatExist(cat.GetBreed().Trim())) { return false; } _catDal.AddCat(cat, changes); return true; }