/// <summary> /// Create a new home /// </summary> /// <param name="home">The home to create</param> /// <param name="user">The user creating the home</param> /// <returns></returns> async Task <Home> IHomeLayer.CreateHome(Home home, Guid user) { return(await this.connectionManager.ExecuteSql( "hub.createhome", collection => { collection.AddWithValue("name", home.Name); collection.AddWithValue("user", user); }, reader => { reader.Read(); return SqlDataLayer.ReadHome(reader); }, this.tokenSource.Token)); }
/// <summary> /// Get the homes for a user /// </summary> /// <param name="user">The user id</param> /// <returns>A list of all homes for this user</returns> async Task <IEnumerable <Home> > IHomeLayer.GetHomes(Guid user) { return(await this.connectionManager.ExecuteSql( "hub.gethomes", collection => { collection.AddWithValue("user", user); }, reader => { var result = new List <Home>(); while (reader.Read()) { result.Add(SqlDataLayer.ReadHome(reader)); } return result; }, this.tokenSource.Token)); }