public IActionResult Put(int id, ArticleCategoryItem item)
 {
     if (ModelState.IsValid)
     {
         var entity = this.db.ArticleCategories.SingleOrDefault(x => x.Id == id);
         if (entity == null)
         {
             return(NotFound());
         }
         entity.Name        = item.Name;
         entity.Description = item.Description;
         this.db.SaveChanges();
         return(NoContent());
     }
     return(BadRequest(ModelState));
 }
 public IActionResult Post(ArticleCategoryItem item)
 {
     if (ModelState.IsValid)
     {
         var entity = new ArticleCategory()
         {
             Name        = item.Name,
             Description = item.Description,
         };
         this.db.Add(entity);
         this.db.SaveChanges();
         item.Id = entity.Id;
         return(CreatedAtAction(nameof(Get), new { id = entity.Id }, item));
     }
     return(BadRequest(ModelState));
 }
 public async Task SaveCategory(ArticleCategoryItem item)
 {
     try
     {
         if (this.categoryModel.Item.Id == 0)
         {
             await service.Create(this.categoryModel.Item);
         }
         else
         {
             await service.Update(this.categoryModel.Item);
         }
         await this.ShowList();
     }
     catch (Exception ex)
     {
         this.error = ex.Message;
     }
 }
Example #4
0
 public async Task EditCategory(ArticleCategoryListItem item)
 {
     this.currentCategory = await service.Get(item.Id);
 }
Example #5
0
 public async Task AddCategory()
 {
     this.currentCategory = await service.GetNew();
 }
Example #6
0
 public async Task ShowList()
 {
     articleCategoryListItems = await service.GetList();;
     this.currentCategory     = null;
 }