Ejemplo n.º 1
0
        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 = ""
            }));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <SecondaryCategory> > PostSecondaryCategory(SecondaryCategory secondaryCategory)
        {
            _context.secondaryCategories.Add(secondaryCategory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSecondaryCategory", new { id = secondaryCategory.Id }, secondaryCategory));
        }
Ejemplo n.º 3
0
        public void DeleteSecondaryCategory(SecondaryCategory secondaryCategory)
        {
            if (secondaryCategory == null)
            {
                throw new ArgumentNullException(nameof(secondaryCategory));
            }

            _context.secondaryCategories.Remove(secondaryCategory);
        }
Ejemplo n.º 4
0
        public void AddSecondaryCategory(SecondaryCategory secondaryCategory)
        {
            if (secondaryCategory == null)
            {
                throw new ArgumentNullException(nameof(secondaryCategory));
            }

            _context.secondaryCategories.Add(secondaryCategory);
        }
Ejemplo n.º 5
0
        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);
        }