示例#1
0
        public async Task <IActionResult> Delete([FromBody] BlackListCustomers _BlackListCustomers)
        {
            BlackListCustomers _blacklist = new BlackListCustomers();

            try
            {
                var VariableEmpleados = _context.BlackListCustomers.Where(a => a.BlackListId == (int)_BlackListCustomers.BlackListId)
                                        .FirstOrDefault();

                if (VariableEmpleados.IdEstado == 2)
                {
                    _blacklist = _context.BlackListCustomers
                                 .Where(x => x.IdEstado == 2)
                                 .FirstOrDefault();
                    _context.BlackListCustomers.Remove(_blacklist);
                    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(_blacklist)));
        }
示例#2
0
        public async Task <IActionResult> GetBlackListByRTN([FromBody] BlackListCustomers _BlackList)
        {
            BlackListCustomers Items = new BlackListCustomers();

            try
            {
                Items = await _context.BlackListCustomers.Where(q => q.RTN == _BlackList.RTN).FirstOrDefaultAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }
            return(await Task.Run(() => Ok(Items)));
        }
示例#3
0
        public async Task <ActionResult <BlackListCustomers> > GetBlackListCustomersByCustomerId(Int64 CustomerId)
        {
            BlackListCustomers Items = new BlackListCustomers();

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


            return(await Task.Run(() => Ok(Items)));
        }
示例#4
0
        public async Task <IActionResult> GetBlackListByParams([FromBody] BlackListCustomers _BlackListCustomers)
        {
            List <BlackListCustomers> Items = new List <BlackListCustomers>();

            try
            {
                Items = await _context.BlackListCustomers.Where(q => q.CustomerName.Contains(_BlackListCustomers.CustomerName)).ToListAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            //  int Count = Items.Count();
            return(await Task.Run(() => Ok(Items)));
        }
示例#5
0
        public async Task <ActionResult <BlackListCustomers> > Insert([FromBody] BlackListCustomers _BlackListCustomers)
        {
            BlackListCustomers _BlackListCustomersq = new BlackListCustomers();

            try
            {
                _BlackListCustomersq = _BlackListCustomers;
                _context.BlackListCustomers.Add(_BlackListCustomersq);
                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(_BlackListCustomersq)));
        }
示例#6
0
        public async Task <ActionResult <BlackListCustomers> > Update([FromBody] BlackListCustomers _BlackListCustomers)
        {
            BlackListCustomers _BlackListCustomersq = _BlackListCustomers;

            try
            {
                _BlackListCustomersq = await(from c in _context.BlackListCustomers
                                             .Where(q => q.BlackListId == _BlackListCustomers.BlackListId)
                                             select c
                                             ).FirstOrDefaultAsync();

                _context.Entry(_BlackListCustomersq).CurrentValues.SetValues((_BlackListCustomers));

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