public int Edit(Administrator Administrator) { PersonsDAO PersonsDAO = new PersonsDAO(strConnection); Administrator.UpdatedOn = DateTime.Now; Person person = Administrator.GetBase(); int edited = PersonsDAO.Edit(person); if (edited <= 0) { return(edited); } using (var sql = new NpgsqlConnection(strConnection)) { var resp = sql.Execute(@"UPDATE Administrators SET Position = @Position WHERE ID=@ID", new { ID = Administrator.ID, Position = Administrator.Position }); return(Administrator.ID); } }
public int Add(Administrator Administrator) { try { PersonsDAO PersonsDAO = new PersonsDAO(strConnection); Administrator.CreatedOn = DateTime.Now; Administrator.UpdatedOn = DateTime.Now; Person person = Administrator.GetBase(); int insertedId = PersonsDAO.Add(person); if (insertedId < 0) { return(insertedId); } Administrator.ID = insertedId; } catch (Exception e) { return(0); } using (var sql = new NpgsqlConnection(strConnection)) { var resp = sql.Execute(@"INSERT INTO Administrators (ID, Position) VALUES (@ID, @Position)", new { ID = Administrator.ID, Position = Administrator.Position }); return(Administrator.ID); } }
public int Edit(Patient Patient) { PersonsDAO PersonsDAO = new PersonsDAO(strConnection); Patient.UpdatedOn = DateTime.Now; Person person = Patient.GetBase(); int edited = PersonsDAO.Edit(person); if (edited <= 0) { return(edited); } using (var sql = new NpgsqlConnection(strConnection)) { var resp = sql.Execute(@"UPDATE Patients SET Profession = @Profession WHERE ID=@ID", new { ID = Patient.ID, Profession = Patient.Profession, }); return(Patient.ID); } }
public int Add(Patient Patient) { try { PersonsDAO PersonsDAO = new PersonsDAO(strConnection); Patient.CreatedOn = DateTime.Now; Patient.UpdatedOn = DateTime.Now; Person person = Patient.GetBase(); int insertedId = PersonsDAO.Add(person); if (insertedId <= 0) { return(insertedId); } Patient.ID = insertedId; } catch (Exception e) { return(0); } using (var sql = new NpgsqlConnection(strConnection)) { var resp = sql.Execute(@"INSERT INTO Patients (ID, Profession) VALUES (@ID, @Profession)", new { ID = Patient.ID, Profession = Patient.Profession, }); return(Patient.ID); } }
public int Edit(Dentist Dentist) { PersonsDAO PersonsDAO = new PersonsDAO(strConnection); Dentist.UpdatedOn = DateTime.Now; Person person = Dentist.GetBase(); int edited = PersonsDAO.Edit(person); if (edited <= 0) { return(edited); } using (var sql = new NpgsqlConnection(strConnection)) { var resp = sql.Execute(@"UPDATE Dentists SET Specialty = @Specialty,CRO = @CRO,Active = @Active WHERE ID=@ID", new { ID = Dentist.ID, Specialty = Dentist.Specialty, CRO = Dentist.CRO, Active = Dentist.Active }); return(Dentist.ID); } }
public int Add(Dentist Dentist) { try { PersonsDAO PersonsDAO = new PersonsDAO(strConnection); Dentist.CreatedOn = DateTime.Now; Dentist.UpdatedOn = DateTime.Now; Person person = Dentist.GetBase(); int insertedId = PersonsDAO.Add(person); if (insertedId < 0) { return(insertedId); } Dentist.ID = insertedId; } catch (Exception e) { return(0); } using (var sql = new NpgsqlConnection(strConnection)) { var resp = sql.Execute(@"INSERT INTO Dentists (ID,Specialty,CRO,Active) VALUES (@ID,@Specialty,@CRO,@Active)", new { ID = Dentist.ID, Specialty = Dentist.Specialty, CRO = Dentist.CRO, Active = Dentist.Active }); return(Dentist.ID); } }