示例#1
0
        public async Task <IActionResult> GetCustomerPartnersById(Int64 PartnerId)
        {
            CustomerPartners Items = new CustomerPartners();

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


            return(await Task.Run(() => Ok(Items)));
        }
示例#2
0
        public async Task <ActionResult <CustomerPartners> > Insert([FromBody] CustomerPartners _CustomerPartners)
        {
            CustomerPartners _CustomerPartnersq = new CustomerPartners();

            try
            {
                _CustomerPartnersq = _CustomerPartners;
                _context.CustomerPartners.Add(_CustomerPartnersq);
                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(_CustomerPartnersq)));
        }
示例#3
0
        public async Task <IActionResult> Delete([FromBody] CustomerPartners _CustomerPartners)
        {
            CustomerPartners _CustomerPartnersq = new CustomerPartners();

            try
            {
                _CustomerPartnersq = _context.CustomerPartners
                                     .Where(x => x.PartnerId == (Int64)_CustomerPartners.PartnerId)
                                     .FirstOrDefault();

                _context.CustomerPartners.Remove(_CustomerPartnersq);
                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(_CustomerPartnersq)));
        }
示例#4
0
        public async Task <ActionResult <CustomerPartners> > Update([FromBody] CustomerPartners _CustomerPartners)
        {
            CustomerPartners _CustomerPartnersq = _CustomerPartners;

            try
            {
                _CustomerPartnersq = await(from c in _context.CustomerPartners
                                           .Where(q => q.PartnerId == _CustomerPartners.PartnerId)
                                           select c
                                           ).FirstOrDefaultAsync();

                _context.Entry(_CustomerPartnersq).CurrentValues.SetValues((_CustomerPartners));

                //_context.CustomerPartners.Update(_CustomerPartnersq);
                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(_CustomerPartnersq)));
        }