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))); }
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))); }
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))); }
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))); }
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))); }
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))); }