コード例 #1
0
        public string BindingSo()
        {
            List <Context.SalesOrder> items = RepoSalesOrder.FindAllAdminDispatched();

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

            foreach (Context.SalesOrder item in items)
            {
                if (item.SalesOrderKontrakId.HasValue)
                {
                    var data = item.SalesOrderKontrak.SalesOrderKontrakListSo.Where(p => p.IsProses && p.Status == "dispatched").GroupBy(d => new { d.IdDataTruck, d.Driver1Id, d.Status, d.Urutan }).Select(grp => grp.ToList());
                    foreach (var itemGroup in data.ToList())
                    {
                        ListModel.Add(new AdminUangJalanIndex(item, itemGroup));
                        foreach (var itemKontrakPerOrder in itemGroup.OrderBy(t => t.MuatDate).ToList())
                        {
                            ListModel.Add(new AdminUangJalanIndex(item, itemGroup.Where(d => d.Id == itemKontrakPerOrder.Id).ToList()));
                        }
                    }
                }
                else
                {
                    ListModel.Add(new AdminUangJalanIndex(item));
                }
            }

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