public async Task AddTask(Item item) { if (item.IsChild) { throw new ArgumentException("Item passed as arguement has a valid Parent_Id"); } var task = (await habiticaClient.CreateTask(item.ToHabiticaTask())).Data; var link = new TodoHabitLink(userId, item.Id, task.Id); await storageClient.InsertOrUpdate(link); await storageClient.InsertOrUpdate(link.Reverse()); }
public async Task AddChecklistItem(Item item) { if (!item.IsChild) { throw new ArgumentException("Item passed as arguement does not have a valid Parent_Id"); } var habiticaTaskId = (await storageClient.RetrieveRecord <TodoHabitLink>(userId, item.Parent_Id)).HabiticaId; var checklistItem = (await habiticaClient.CreateChecklistItem(item.ToHabiticaChecklistItem(), habiticaTaskId)).Data.Checklist .First(x => x.Text == item.Content); var link = new TodoHabitLink(userId, item.Id, checklistItem.Id, item.Parent_Id); await storageClient.InsertOrUpdate(link); await storageClient.InsertOrUpdate(link.Reverse(habiticaTaskId)); }