public bool AddDoctor(Doctor doctor) { try { doctor.ID = Guid.NewGuid(); db.Insert(doctor); } catch (Exception) { return false; } return true; }
public bool UpdateDoctor(Guid ID, Doctor doctor) { try { db.Update(doctor); } catch (Exception) { return false; } return true; }
public bool Delete(Doctor doctor) { throw new NotImplementedException(); }
public bool Insert(Doctor doctor) { throw new NotImplementedException(); }
public bool Delete(Doctor doctor) { string sqlQuery = "Delete from [dbo].[doctors] where [id] = @ID"; var result = false; using (var conn = new SqlConnection(connectionString)) { conn.Open(); conn.Execute(sqlQuery, new { doctor.ID, }); result = true; } return result; }
public bool Update(Doctor doctor) { string sqlQuery = "Update [dbo].[doctors] set [name] = @Name where [id] = @ID"; var result = false; using (var conn = new SqlConnection(connectionString)) { conn.Open(); conn.Execute(sqlQuery, new { doctor.ID, doctor.Name }); result = true; } return result; }
public bool Insert(Doctor doctor) { string sqlQuery = "INSERT INTO [dbo].[doctors]([id],[name]) VALUES (@ID,@Name)"; var result = false; using (var conn = new SqlConnection(connectionString)) { conn.Open(); conn.Execute(sqlQuery, new { doctor.ID, doctor.Name }); result = true; } return result; }