public async Task <IEnumerable <MtrVendedor> > ListvendedoresPorUsuario(MtrVendedorQueryFilter filter) { List <MtrVendedor> result = new List <MtrVendedor>(); string usuario = filter.Usuario; var vendedor = await _context.MtrVendedor.Where(x => x.Codigo == usuario && x.Activo == "X").FirstOrDefaultAsync(); if (vendedor != null) { result = await _context.MtrVendedor.Where(x => x.Codigo == usuario && x.Activo == "X" && x.CotizadorPlus == "X").ToListAsync(); } var supervisor = await _context.MtrVendedor.Where(x => x.Supervisor == usuario).FirstOrDefaultAsync(); if (supervisor != null) { result = await _context.MtrVendedor.Where(x => x.Supervisor == usuario && x.Activo == "X" && x.CotizadorPlus == "X").ToListAsync(); } var cobRolCobranza = await _context.CobRolCobranza.Where(x => x.IdUsuario == usuario).ToListAsync(); if (cobRolCobranza.Count > 0) { foreach (var item in cobRolCobranza) { var vend = await _context.MtrVendedor.Where(x => x.Oficina == item.IdOficina && x.Activo == "X" && x.CotizadorPlus == "X").ToListAsync(); foreach (var itemvend in vend) { result.Add(itemvend); } } } var usuarioOficina = await _context.MtrUsuarioOficina.Where(x => x.Usuario == usuario).ToListAsync(); if (usuarioOficina.Count > 0) { foreach (var item in usuarioOficina) { var vend = await _context.MtrVendedor.Where(x => x.Oficina == item.Oficina && x.Activo == "X" && x.CotizadorPlus == "X").ToListAsync(); foreach (var itemvend in vend) { result.Add(itemvend); } } } if (filter.Oficina > 0) { result = await _context.MtrVendedor.Where(x => x.Oficina == filter.Oficina && x.Activo == "X" && x.CotizadorPlus == "X").ToListAsync(); } return(result); }
public async Task <IActionResult> ListVendedoresPorUsuario(MtrVendedorQueryFilter filters) { IEnumerable <MtrVendedor> vendedores = await _mtrVendedorService.ListVendedoresPorUsuario(filters); IEnumerable <MtrVendedorDto> vendedoressDtos = _mapper.Map <IEnumerable <MtrVendedorDto> >(vendedores); ApiResponse <IEnumerable <MtrVendedorDto> > response = new ApiResponse <IEnumerable <MtrVendedorDto> >(vendedoressDtos); return(Ok(response)); }
public async Task <IEnumerable <MtrVendedor> > ListVendedoresPorUsuario(MtrVendedorQueryFilter filter) { return(await _unitOfWork.MtrVendedorRepository.ListvendedoresPorUsuario(filter)); }