Пример #1
0
        public ActionResult GetAjaxHandlerMakeDelivery(Guid clientID, Guid deliveryID)
        {
            try
            {
                //Busca preço de produtos por clientes. Deve sempre existir preço para todos clientes
                var boxesProductItemsVM = _boxService.GetOrderProductItemByDeliveryID(deliveryID);

                var orderProductItemsGroup = boxesProductItemsVM.GroupBy(item => item.Product.DT_RowId,
                                                                         (key, group) => new {
                    DT_RowId          = key,
                    Product           = group.Select(x => x.Product).FirstOrDefault(),
                    ProductName       = group.Select(x => x.Product.Name).FirstOrDefault(),
                    PictureID         = group.Select(x => x.Product.PictureID).FirstOrDefault(),
                    TotalProductItems = group.Select(p => p).Count(),                                                  //TotalProductItems
                    BoxType           = group.SelectMany(b => b.BoxesProductItems).GroupBy(b => b.Box.BoxTypeID,
                                                                                           (k, g) => new {
                        DT_RowId       = k,
                        BTypeName      = g.Select(x => x.Box.BoxType.Name).FirstOrDefault(),
                        BTypePictureID = g.Select(x => x.Box.BoxType.PictureID.Value).FirstOrDefault(),
                        Total          = g.Select(x => x.BoxID).Distinct().Count(),
                        MaxBox         = g.Select(x => x.Box.BoxType.MaxProductsItems).FirstOrDefault()
                    }).FirstOrDefault()
                })
                                             .ToList();

                return(Json(new
                {
                    aaData = orderProductItemsGroup.Select(x => new
                    {
                        DT_RowId = x.DT_RowId.ToString(),
                        x.ProductName,
                        Product = new
                        {
                            x.Product.Description,
                            x.Product.Package,
                            Capacity = $"{x.Product.Capacity} {x.Product.UnitMeasure}",
                            Weight = $"{x.Product.Weight} {x.Product.MassUnitWeight}"
                        },
                        x.BoxType,
                        x.PictureID,
                        x.TotalProductItems,
                        Total = String.Format("{0:c}", 0)
                    }),
                    success = true,
                    SaldoAnterior = 0,
                    CaixasEmDebito = 0
                }));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public ActionResult GetAjaxHandlerExecuteSale(string clienteID, string linhaID, string orderID)
        {
            try
            {
                Guid clientID = new Guid(clienteID);

                //Busca preço de produtos por clientes. Deve sempre existir preço para todos clientes
                var clientsProductsVM   = _productService.GetClientsProductsByClientID(clientID);
                var boxesProductItemsVM = _boxService.GetOrderProductItemByDeliveryID(new Guid(orderID));

                //if (clientsProductsVM.Count == 0)
                //    throw CustomException.Create<SaleController>("There aren't products for this client.", nameof(this.GetAjaxHandlerExecuteSale));

                var boxesProductItemsGroup = boxesProductItemsVM.GroupBy(item => item.Product.DT_RowId,
                                                                         (key, group) => new {
                    DT_RowId    = key,
                    Product     = group.Select(x => x.Product).FirstOrDefault(),
                    NomeProduto = group.Select(x => x.Product.Name).FirstOrDefault(),
                    PictureID   = group.Select(x => x.Product.PictureID).FirstOrDefault(),
                    TotalBox    = group.Select(p => p).Count()
                })
                                             .ToList();

                return(Json(new
                {
                    aaData = boxesProductItemsGroup.Select(x => new
                    {
                        DT_RowId = x.DT_RowId.ToString(),
                        x.NomeProduto,
                        Product = new
                        {
                            x.Product.Description,
                            x.Product.Package,
                            Capacity = $"{x.Product.Capacity} {x.Product.UnitMeasure}",
                            Weight = $"{x.Product.Weight} {x.Product.MassUnitWeight}"
                        },
                        x.PictureID,
                        ValorProduto = String.Format("{0:c}", (from c in clientsProductsVM where c.ProductID.ToString() == x.DT_RowId select c.Price).FirstOrDefault()),
                        x.TotalBox,
                        Total = String.Format("{0:c}", 0)
                    }),
                    success = true,
                    SaldoAnterior = 0,
                    CaixasEmDebito = 0
                }));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }