Exemplo n.º 1
0
        public string BindingSalesOrder()
        {
            GridRequestParameters param = GridRequestParameters.Current;

            List <Context.SalesOrder> items = RepoSalesOrder.FindAllKlaim();

            List <ListOrder> ListModel = new List <ListOrder>();

            foreach (Context.SalesOrder item in items)
            {
                if (item.SalesOrderKontrakId.HasValue)
                {
                    if (item.SalesOrderKontrak.SalesOrderKontrakListSo.Any(p => p.IsProses))
                    {
                        foreach (var itemKontrak in item.SalesOrderKontrak.SalesOrderKontrakListSo.Where(s => s.Status == "dispatched" || s.Status == "settlement").GroupBy(d => new { d.IdDataTruck, d.Driver1Id, d.Status, d.Urutan }).Select(grp => grp.ToList()))
                        {
                            foreach (var itemKontrakPerOrder in itemKontrak.OrderBy(t => t.MuatDate).ToList())
                            {
                                ListModel.Add(new ListOrder(item, itemKontrakPerOrder));
                            }
                        }
                    }
                    else
                    {
                        ListModel.Add(new ListOrder(item));
                    }
                }
                else
                {
                    ListModel.Add(new ListOrder(item));
                }
            }

            return(new JavaScriptSerializer().Serialize(new { total = ListModel.Count, data = ListModel }));
        }