public void Dispose() { if (_db == null) { return; } _db.Dispose(); _db = null; }
// GET api/people/5 public Data.DTOs.Policy GetPolicy(int id) { Data.DTOs.Policy policy; using (var ctx = new ContosoInsuranceContext(_connectionString)) { policy = PolicyMapping.MapEntityToDto(ctx.Policies.FirstOrDefault(p => p.Id == id)); } return(policy); }
public Contoso.Apps.Insurance.Data.DTOs.Dependent GetDependent(int id) { Contoso.Apps.Insurance.Data.DTOs.Dependent dependent; using (var ctx = new ContosoInsuranceContext()) { dependent = DependentMapping.MapEntityToDto(ctx.Dependents.FirstOrDefault(p => p.Id == id)); } return(dependent); }
// GET api/policies public IList <Data.DTOs.Policy> GetPolicies() { List <Data.DTOs.Policy> policies; using (var ctx = new ContosoInsuranceContext(_connectionString)) { policies = ctx.Policies.ToList().Select(PolicyMapping.MapEntityToDto).ToList(); } return(policies); }
public Contoso.Apps.Insurance.Data.DTOs.Person GetPerson(int id) { Contoso.Apps.Insurance.Data.DTOs.Person person; using (var ctx = new ContosoInsuranceContext()) { person = PersonMapping.MapEntityToDto(ctx.People.FirstOrDefault(p => p.Id == id)); } return(person); }
public IList <Contoso.Apps.Insurance.Data.DTOs.Person> GetAllPeople() { List <Contoso.Apps.Insurance.Data.DTOs.Person> people; using (var ctx = new ContosoInsuranceContext()) { people = ctx.People.OrderBy(p => p.LName).ToList().Select(PersonMapping.MapEntityToDto).ToList(); } return(people); }
// GET api/people/5 public Data.DTOs.Person GetPerson(int id) { Data.DTOs.Person person; using (var ctx = new ContosoInsuranceContext(_connectionString)) { person = PersonMapping.MapEntityToDto(ctx.People.FirstOrDefault(p => p.Id == id)); } return(person); }
// GET api/dependents/5 public Dependent GetDependent(int id) { Dependent dependent; // TODO: Review using (var ctx = new ContosoInsuranceContext(_connectionString)) { dependent = DependentMapping.MapEntityToDto(ctx.Dependents.FirstOrDefault(p => p.Id == id)); } return(dependent); }
public IList <Contoso.Apps.Insurance.Data.DTOs.PolicyHolder> GetPolicyHolders() { List <PolicyHolder> policies; using (var ctx = new ContosoInsuranceContext()) { var policyHolders = ctx.PolicyHolders.Include(p => p.Policy).Include(p => p.Person) .Include(p => p.Dependents).OrderBy(p => p.Person.LName).ToList(); policies = policyHolders.Select(PolicyHolderMapping.MapEntityToDto).ToList(); } return(policies); }
public PolicyHolder GetPolicyHolder(int id) { PolicyHolder policyHolder; using (var ctx = new ContosoInsuranceContext()) { var policyHolderData = ctx.PolicyHolders.Include(p => p.Policy) .Include(p => p.Person).Include(p => p.Dependents).FirstOrDefault(p => p.Id == id); policyHolder = PolicyHolderMapping.MapEntityToDto(policyHolderData); } return(policyHolder); }
// GET api/policyholders public IList<PolicyHolderViewModel> GetPolicyHolders() { List<PolicyHolderViewModel> policies; using (var ctx = new ContosoInsuranceContext(_connectionString)) { var policyHolders = ctx.PolicyHolders.Include(p => p.Policy).Include(p => p.Person) .Include(p => p.Dependents).OrderBy(p => p.Person.LName).ToList(); policies = policyHolders.Select(PolicyHolderMapping.MapEntityToViewModel).ToList(); } return policies; }
public DependentActions(string connectionString = null) { // TODO: Review _db = !string.IsNullOrWhiteSpace(connectionString) ? new ContosoInsuranceContext(connectionString) : new ContosoInsuranceContext(); }