Пример #1
0
        public string Binding(DailyFilterModel model)
        {
            //kamus
            List <rent>         rents;
            List <driver>       drivers;
            List <expense_item> expenseItems;
            Guid     idOwner = (User as CustomPrincipal).IdOwner.Value;
            DateTime dtStart, dtEnd;

            Business.Infrastructure.FilterInfo filters;

            //algoritma
            //items = RepoExpense.GetDriverReport(idOwner, model.StartDate, model.EndDate);

            dtStart = new DateTime(model.StartDate.Year, model.StartDate.Month, model.StartDate.Day, 0, 0, 0);
            dtEnd   = new DateTime(model.EndDate.Year, model.EndDate.Month, model.EndDate.Day, 23, 59, 59);

            //mengambil data booking
            rents = RepoRent.FindAll(idOwner, dtStart, dtEnd);

            //mengambil data driver
            filters = new Business.Infrastructure.FilterInfo
            {
                Filters = new List <Business.Infrastructure.FilterInfo>
                {
                    new Business.Infrastructure.FilterInfo {
                        Field = "id_owner", Operator = "eq", Value = idOwner.ToString()
                    },
                }
            };
            drivers = RepoDriver.FindAll(null, null, null, filters);

            //mengambil data epneseItem untuk pemasukan
            filters = new Business.Infrastructure.FilterInfo
            {
                Filters = new List <Business.Infrastructure.FilterInfo>
                {
                    new Business.Infrastructure.FilterInfo {
                        Field = "expense.date", Operator = "gte", Value = dtStart.ToString()
                    },
                    new Business.Infrastructure.FilterInfo {
                        Field = "expense.date", Operator = "lte", Value = dtEnd.ToString()
                    },
                    new Business.Infrastructure.FilterInfo {
                        Field = "category", Operator = "eq", Value = ExpenseItemCategory.DRIVER.ToString()
                    },
                    new Business.Infrastructure.FilterInfo {
                        Field = "expense.rent.id_owner", Operator = "eq", Value = idOwner.ToString()
                    },
                }
            };
            expenseItems = RepoExpense.FindAllItem(null, null, null, filters);

            return(new JavaScriptSerializer().Serialize(new SummaryStub().MapList(drivers, rents, expenseItems)));
        }
Пример #2
0
        public string BindingItem()
        {
            //kamus
            GridRequestParameters param = GridRequestParameters.Current;

            Business.Infrastructure.FilterInfo filters = param.Filters;

            int total = 0;
            //expense expenseSet = new expense();
            //List<expense_item> items = RepoExpense.FindAllItem().Where(x => x.id_expense == expenseSet.id).ToList();
            List <expense_item> items = new List <expense_item>();

            items = RepoExpense.FindAllItem(param.Skip, param.Take, (param.Sortings != null ? param.Sortings.ToList() : null), param.Filters);
            total = RepoExpense.CountItem(param.Filters);

            return(new JavaScriptSerializer().Serialize(new { total = total, data = new CostPresentationStub().MapListItem(items) }));
        }
Пример #3
0
        //public JsonResult Binding(DailyFilterModel model)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        Guid idOwner = (User as CustomPrincipal).IdOwner.Value;
        //        List<VehicleExpenseReport> result = RepoExpense.GetVehicleReport(idOwner, model.StartDate, model.EndDate);
        //        List<rent> rents = RepoRent.FindAll();
        //        return Json(new CarReportPresentationStub().MapList(result, rents), JsonRequestBehavior.AllowGet);
        //    }
        //    else
        //    {
        //        return Json(false, JsonRequestBehavior.AllowGet);
        //    }
        //}

        //private void AddExpenseFilter(Business.Infrastructure.FilterInfo filters, Guid idRents)
        //{
        //    if (filters == null)
        //        filters = new Business.Infrastructure.FilterInfo { Filters = new List<Business.Infrastructure.FilterInfo>(), Logic = "and" };

        //    if (filters.Filters == null)
        //        filters.Filters = new List<Business.Infrastructure.FilterInfo>();
        //    else
        //    {
        //            filters.Filters.Add(new Business.Infrastructure.FilterInfo { Field = "id_rent", Operator = "eq", Value = idRents });
        //    }
        //}


        public JsonResult Binding(DailyFilterModel model)
        {
            if (ModelState.IsValid)
            {
                //kasmus
                Guid idOwner = (User as CustomPrincipal).IdOwner.Value;

                Business.Infrastructure.FilterInfo filters;

                List <rent>         rents;
                List <expense_item> expenseItem;
                List <car>          cars;
                List <car_expense>  carExpenses;
                DateTime            dtStart, dtEnd;

                //algoritma
                dtStart = new DateTime(model.StartDate.Year, model.StartDate.Month, model.StartDate.Day, 0, 0, 0);
                dtEnd   = new DateTime(model.EndDate.Year, model.EndDate.Month, model.EndDate.Day, 23, 59, 59);

                //mengambil car yang statusnya active
                filters = new Business.Infrastructure.FilterInfo
                {
                    Filters = new List <Business.Infrastructure.FilterInfo>
                    {
                        new Business.Infrastructure.FilterInfo {
                            Field = "is_active", Operator = "eq", Value = true.ToString()
                        },
                        new Business.Infrastructure.FilterInfo {
                            Field = "id_owner", Operator = "eq", Value = idOwner.ToString()
                        }
                    }
                };
                cars = RepoCar.FindAll(null, null, null, filters);

                //mengambil data booking
                rents = RepoRent.FindAll(idOwner, dtStart, dtEnd);

                //mengambil expense_item (pemasukan kendaraan)
                filters = new Business.Infrastructure.FilterInfo
                {
                    Filters = new List <Business.Infrastructure.FilterInfo>
                    {
                        new Business.Infrastructure.FilterInfo {
                            Field = "expense.date", Operator = "gte", Value = dtStart.ToString()
                        },
                        new Business.Infrastructure.FilterInfo {
                            Field = "expense.date", Operator = "lte", Value = dtEnd.ToString()
                        },
                        new Business.Infrastructure.FilterInfo {
                            Field = "category", Operator = "eq", Value = ExpenseItemCategory.VEHICLE.ToString()
                        },
                        new Business.Infrastructure.FilterInfo {
                            Field = "expense.rent.id_owner", Operator = "eq", Value = idOwner.ToString()
                        }
                    }
                };
                expenseItem = RepoExpense.FindAllItem(null, null, null, filters);

                //mengambil carExpense (biaya kendaraan)
                filters = new Business.Infrastructure.FilterInfo
                {
                    Filters = new List <Business.Infrastructure.FilterInfo>
                    {
                        new Business.Infrastructure.FilterInfo {
                            Field = "expense_date", Operator = "gte", Value = dtStart.ToString()
                        },
                        new Business.Infrastructure.FilterInfo {
                            Field = "expense_date", Operator = "lte", Value = dtEnd.ToString()
                        },
                        new Business.Infrastructure.FilterInfo {
                            Field = "car.id_owner", Operator = "eq", Value = idOwner.ToString()
                        }
                    }
                };
                carExpenses = RepoCarExpense.FindAll(null, null, null, filters);

                return(Json(new CarReportPresentationStub().MapList(cars, rents, expenseItem, carExpenses), JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }