/// <summary> /// Updates category info. /// </summary> /// <param name="id"></param> /// <param name="category"></param> /// <returns></returns> public async Task<bool> UpdateCategory(int id, Category category) { var _category = new Category { Id = category.Id, Name = category.Name, CategoryId = category.CategoryId }; var response = await client.PutAsJsonAsync(uriCategories+"/"+id, _category); if (response.IsSuccessStatusCode) { return true; } return false; }
/// <summary> /// Adds category to database. /// </summary> /// <param name="category"></param> /// <returns></returns> public async Task<bool> AddCategory(Category category) { var _category = new Category { CategoryId = category.CategoryId, Name = category.Name, ChildCategories = category.ChildCategories, ParentCategory = category.ParentCategory }; HttpResponseMessage response = await client.PostAsJsonAsync(uriCategories, _category); if (response.IsSuccessStatusCode) { return true; } return false; }