using Service_Server.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Service_Server.DB { class Person_DB { public List GetAllPersons() { using (DATABASE ctx = new DATABASE()) { return ctx.Persons.ToList(); } } public bool CreatePerson(Person person) { try { using (DATABASE ctx = new DATABASE()) { ctx.Persons.Add(person); ctx.SaveChanges(); } return true; } catch (Exception) { return false; } } public bool UpdatePerson(Person person) { try { using (DATABASE ctx = new DATABASE()) { ctx.Persons.Attach(person); ctx.Entry(person).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } return true; } catch (Exception) { return false; } } public bool DeletePerson(Person person) { try { using (DATABASE ctx = new DATABASE()) { ctx.Persons.Attach(person); ctx.Persons.Remove(person); ctx.SaveChanges(); } return true; } catch (Exception) { return false; } } } }