public Policy Get(int id) { using (InsuranceContext context = new InsuranceContext()) { return(context.Policies.Where(c => c.Id == id).FirstOrDefault()); } }
public IEnumerable <Policy> Get() { using (InsuranceContext context = new InsuranceContext()) { return(context.Policies.ToList()); } }
public Client Get(int id) { using (InsuranceContext context = new InsuranceContext()) { return(context.Clients.Where(c => c.Id == id).FirstOrDefault()); } }
public IEnumerable <Client> Get() { using (InsuranceContext context = new InsuranceContext()) { return(context.Clients.ToList()); } }
public void Create(Policy policy) { using (InsuranceContext context = new InsuranceContext()) { context.Policies.Add(policy); context.SaveChanges(); } }
public void Create(Client client) { using (InsuranceContext context = new InsuranceContext()) { context.Clients.Add(client); context.SaveChanges(); } }
public void Delete(int id) { using (InsuranceContext context = new InsuranceContext()) { var current = context.Policies.Find(id); context.Policies.Remove(current); context.SaveChanges(); } }
public void Update(Policy policy) { using (InsuranceContext context = new InsuranceContext()) { var current = context.Policies.Find(policy.Id); if (current == null) { return; } context.Entry(current).CurrentValues.SetValues(policy); context.SaveChanges(); } }
public void Update(Client client) { using (InsuranceContext context = new InsuranceContext()) { var current = context.Clients.Find(client.Id); if (current == null) { return; } context.Entry(current).CurrentValues.SetValues(client); context.SaveChanges(); } }