public async Task <IActionResult> GetProductUserRelationById(Int64 ProductUserRelationId)
        {
            ProductUserRelation Items = new ProductUserRelation();

            try
            {
                Items = await _context.ProductUserRelation.Where(q => q.ProductUserRelationId == ProductUserRelationId).FirstOrDefaultAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }


            return(await Task.Run(() => Ok(Items)));
        }
        public async Task <ActionResult <ProductUserRelation> > Insert([FromBody] ProductUserRelation _ProductUserRelation)
        {
            ProductUserRelation _ProductUserRelationq = new ProductUserRelation();

            try
            {
                _ProductUserRelationq = _ProductUserRelation;
                _context.ProductUserRelation.Add(_ProductUserRelationq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_ProductUserRelationq)));
        }
        public async Task <IActionResult> Delete([FromBody] ProductUserRelation _ProductUserRelation)
        {
            ProductUserRelation _ProductUserRelationq = new ProductUserRelation();

            try
            {
                _ProductUserRelationq = _context.ProductUserRelation
                                        .Where(x => x.ProductUserRelationId == (Int64)_ProductUserRelation.ProductUserRelationId)
                                        .FirstOrDefault();

                _context.ProductUserRelation.Remove(_ProductUserRelationq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}")));
            }

            return(await Task.Run(() => Ok(_ProductUserRelationq)));
        }
        public async Task <ActionResult <ProductUserRelation> > Update([FromBody] ProductUserRelation _ProductUserRelation)
        {
            ProductUserRelation _ProductUserRelationq = _ProductUserRelation;

            try
            {
                _ProductUserRelationq = await(from c in _context.ProductUserRelation
                                              .Where(q => q.ProductUserRelationId == _ProductUserRelation.ProductUserRelationId)
                                              select c
                                              ).FirstOrDefaultAsync();

                _context.Entry(_ProductUserRelationq).CurrentValues.SetValues((_ProductUserRelation));

                //_context.ProductUserRelation.Update(_ProductUserRelationq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}")));
            }

            return(await Task.Run(() => Ok(_ProductUserRelationq)));
        }