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);
        }
        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);
        }