public Task SaveAsync(SearchCategory category) { if (category.Id == Guid.Empty) { return CreateAsync(category); } else { return UpdateAsync(category); } }
public Task CreateAsync(SearchCategory category) { if (category == null) throw new ArgumentNullException("category"); return Task.Factory.StartNew(() => { category.Id = Guid.NewGuid(); using (IDbConnection connection = CurrentContext.OpenConnection()) connection.Execute("insert into app_SearchCategories(Id, Name) values(@Id, @Name)", category); }); }
public Task UpdateAsync(SearchCategory category) { if (category == null) throw new ArgumentNullException("category"); return Task.Factory.StartNew(() => { using (IDbConnection connection = CurrentContext.OpenConnection()) connection.Execute("update app_SearchCategories SET Name=@Name where Id = @Id", category); }); }