public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name,DateCreated")] Category category)
        {
            if (id != category.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Exemplo n.º 2
0
        public IActionResult Update(int id, [FromBody] Category catObject)
        {
            if (catObject == null)
            {
                return(BadRequest());
            }
            _context.Update(catObject);

            return(CreatedAtRoute("GetAll", null));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> EditCategory(Category category)
        {
            //   TypeArticle.GamblingAddiction.GetDisplayName();
            if (ModelState.IsValid)
            {
                await _categoryContext.Update(category);

                return(RedirectToAction("CategoryList"));
            }
            return(View("Category/EditCategory", category));
        }
Exemplo n.º 4
0
 public void Update(Category category)
 {
     categoryContext.Update(category);
     categoryContext.SaveChanges();
 }