public async Task <IActionResult> PutSecondaryCategory(int id, SecondaryCategory secondaryCategory) { if (id != secondaryCategory.Id) { return(BadRequest()); } _context.Entry(secondaryCategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SecondaryCategoryExists(id)) { return(NotFound()); } else { throw; } } return(new JsonResult(new Result <SecondaryCategory>() { Data = secondaryCategory, ErrorCode = CommonConst.ERR_CODE_SUCCESS, ErrorMessage = "" })); }
public async Task <ActionResult <SecondaryCategory> > PostSecondaryCategory(SecondaryCategory secondaryCategory) { _context.secondaryCategories.Add(secondaryCategory); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSecondaryCategory", new { id = secondaryCategory.Id }, secondaryCategory)); }
public void DeleteSecondaryCategory(SecondaryCategory secondaryCategory) { if (secondaryCategory == null) { throw new ArgumentNullException(nameof(secondaryCategory)); } _context.secondaryCategories.Remove(secondaryCategory); }
public void AddSecondaryCategory(SecondaryCategory secondaryCategory) { if (secondaryCategory == null) { throw new ArgumentNullException(nameof(secondaryCategory)); } _context.secondaryCategories.Add(secondaryCategory); }
public void UpdateSecondaryCategory(SecondaryCategory secondaryCategory) { if (secondaryCategory == null) { throw new ArgumentNullException(nameof(secondaryCategory)); } if (!SecondaryExists(secondaryCategory.Id)) { throw new ArgumentException(nameof(secondaryCategory.Id)); } _context.secondaryCategories.Update(secondaryCategory); }