
import Ember from 'ember';
import Family from 'web/models/family';
import FamilyMember from 'web/models/familyMember';
import ListResult from 'web/models/listResult';


export default Ember.Service.extend({
  client: Ember.inject.service('client'),
  searchFamilies:function(){
    const client = this.get('client');
    let results = ListResult.create({childType:Family});

    let searchUrl = '/auditioner/families';

    client.getResource(searchUrl,results);

    return results;
  },
  loadFamilyById:function(familyId)
  {
    const client = this.get('client');
    const url = '/auditioner/families/' + familyId;

    const family = Family.create();

    family.set('client',client);
    family.set('path',url);

    client.getResource(url,family);

    return family;
  },
  reloadFamily:function(family)
  {
    const client = this.get('client');

    client.getResource(family.get('location'),family);

    return family;
  },
  deleteFamily:function(family)
  {
    const client = this.get('client');

    return client.deleteResource(family);
  },
  createFamily:function()
  {
    const client = this.get('client');
    const family = Family.create();
    family.set('client',client);
    return family;
  },
  deleteFamilyMember:function(familyMember)
  {
    const client = this.get('client');

    return client.deleteResource(familyMember);
  },
  createFamilyMember:function()
  {
    const client = this.get('client');
    const familyMember = FamilyMember.create();
    familyMember.set('client',client);
    return familyMember;
  }

});

@@ -775,16 +775,134 @@
 y;%0A  %7D,%0A
+  saveFamily:function(family)%0A  %7B%0A    const client = this.get('client');%0A%0A    return client.putResource(family);%0A  %7D,%0A
   reload
@@ -1665,14 +1665,159 @@
 ber;%0A  %7D
+,%0A  saveFamilyMember:function(saveFamilyMember)%0A  %7B%0A    const client = this.get('client');%0A%0A    return client.putResource(saveFamilyMember);%0A  %7D,
 %0A%0A%7D);%0A

Add save methods