예제 #1
0
        public void EditCategory(libraryNaturguiden.PictureCategory category)
        {
            var dbCategory = db.Category.Where(x => x.Id == category.Id).FirstOrDefault();

            dbCategory.Name = category.Name;
            db.SaveChanges();
        }
예제 #2
0
        public static async Task <HttpStatusCode> UpdateCategoryAsync(libraryNaturguiden.PictureCategory category)
        {
            Setup();
            HttpResponseMessage response = await client.PutAsJsonAsync($"api/PictureCategory/{category.Id}", category);

            response.EnsureSuccessStatusCode();

            return(response.StatusCode);
        }
예제 #3
0
        public void AddCategory(libraryNaturguiden.PictureCategory newCategory)
        {
            var category = new Category
            {
                Id   = newCategory.Id,
                Name = newCategory.Name
            };

            db.Category.Add(category);
            db.SaveChanges();
        }
예제 #4
0
        public static async Task <libraryNaturguiden.PictureCategory> GetCategoryAsync(int id)
        {
            Setup();
            libraryNaturguiden.PictureCategory category = null;
            HttpResponseMessage response = await client.GetAsync($"api/PictureCategory/{id}");

            if (response.IsSuccessStatusCode)
            {
                category = await response.Content.ReadAsAsync <libraryNaturguiden.PictureCategory>();
            }
            return(category);
        }