예제 #1
0
        public void Remove(TModel entity)
        {
            if (_context.Entry(entity).State == EntityState.Detached)
            {
                _modelDbSets.Attach(entity);
            }

            _modelDbSets.Remove(entity);
        }
예제 #2
0
        public async Task <IActionResult> PutUserModel(Guid id, UserModel userModel)
        {
            if (id != userModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(userModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        public async Task <IActionResult> PutProduct(Guid id, ProductModel product)
        {
            if (id != product.Id)
            {
                return(BadRequest());
            }

            _context.Entry(product).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }