Ejemplo n.º 1
0
        public async Task <IActionResult> OrderErrorList()
        {
            //var user = await _workContext.GetCurrentUser();

            /*var rolesNames = _userRepository.Query()
             *  .Where(x => x.UserGuid == user.UserGuid)
             *  .Include(x => x.Roles)
             *      .ThenInclude(x => x.Role)
             *  .Select(x => x.Roles.SelectMany(y => y.Role.Name)).ToList();*/

            var rolesNames = _workContext.GetRolesForCurrentUser();

            var orders = (await _orderRepository.List().ToListAsync())
                         .Where(x => rolesNames.Contains(x.ORDER_TYPE, StringComparer.InvariantCultureIgnoreCase))
                         .Select(x => new OrderDetailVm
            {
                Id             = x.Id,
                OrderType      = x.ORDER_TYPE,
                OrderLegacy    = x.PEDIDO_LEGADO,
                Attendence     = x.LOTE_ATENDIMENTO,
                UpdateTimeSap  = x.UPDATE_TIME_SAP,
                Error          = x.ERRO,
                DocumentNumber = x.CNPJ,
                ClientName     = x.Cliente,
                OrderIssue     = x.REGRA_LIBERACAO,
                Selected       = false
            })
                         .OrderByDescending(x => x.UpdateTimeSap);

            var model = new OrderSelecionViewModel();

            model.Order.AddRange(orders);

            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <IViewComponentResult> InvokeAsync(WidgetInstanceViewModel widgetInstance)
        {
            var model = new OrderIssuesWidgetComponentVm
            {
                Id         = widgetInstance.Id,
                WidgetName = widgetInstance.Name
                             //Items = JsonConvert.DeserializeObject<List<OrderIssuesWidgetSetting>>(widgetInstance.Data)
            };

            var rolesNames = _workContext.GetRolesForCurrentUser();

            model.Items = (await _orderRepository.List().ToListAsync())
                          .GroupBy(x => x.ORDER_TYPE)
                          .Select(group => new OrderIssuesWidgetPanelVm
            {
                OrderType = group.Key,
                Count     = group.Count()
            })
                          .Where(x => rolesNames.Contains(x.OrderType, StringComparer.InvariantCultureIgnoreCase))
                          .OrderBy(x => x.OrderType).ToList();

            return(View(this.GetViewPath(), model));
        }