Exemple #1
0
        private DailyFilterModel ParseFilterInfo(Business.Infrastructure.FilterInfo filter)
        {
            DailyFilterModel fm = new DailyFilterModel();

            Business.Infrastructure.FilterInfo single;

            if (filter != null && filter.Filters != null)
            {
                single = filter.Filters.Where(m => m.Field == "StartDate").FirstOrDefault();
                if (single != null)
                {
                    fm.StartDate = DateTime.Parse(single.Value);
                    fm.StartDate = new DateTime(fm.StartDate.Year, fm.StartDate.Month, 1, 0, 0, 0);
                }

                single = filter.Filters.Where(m => m.Field == "EndDate").FirstOrDefault();
                if (single != null)
                {
                    fm.EndDate = DateTime.Parse(single.Value);
                    fm.EndDate = fm.EndDate.AddMonths(1);
                    fm.EndDate = new DateTime(fm.EndDate.Year, fm.EndDate.Month, 1, 23, 59, 59);
                    fm.EndDate = fm.EndDate.AddDays(-1);
                }
            }

            return(fm);
        }
Exemple #2
0
        private DailyFilterModel ParseFilterInfo(Business.Infrastructure.FilterInfo filter)
        {
            DailyFilterModel fm = new DailyFilterModel();

            Business.Infrastructure.FilterInfo single;
            DateTime start, end;

            if (filter != null && filter.Filters != null)
            {
                single = filter.Filters.Where(m => m.Field == "StartDate").FirstOrDefault();
                if (single != null)
                {
                    start        = DateTime.Parse(single.Value);
                    fm.StartDate = new DateTime(start.Year, start.Month, start.Day, 0, 0, 0);
                }

                single = filter.Filters.Where(m => m.Field == "EndDate").FirstOrDefault();
                if (single != null)
                {
                    end        = DateTime.Parse(single.Value);
                    fm.EndDate = new DateTime(end.Year, end.Month, end.Day, 23, 59, 59);
                }

                single = filter.Filters.Where(m => m.Field == "CarModelName").FirstOrDefault();
                if (single != null)
                {
                    fm.CarModelName = single.Value;
                }
            }

            return(fm);
        }
Exemple #3
0
        public ActionResult Detail(Guid id, DateTime startDate, DateTime endDate)
        {
            DailyFilterModel filter = new DailyFilterModel(startDate, endDate);
            driver           d      = RepoDriver.FindByPk(id);

            ViewBag.DriverId   = id;
            ViewBag.DriverName = d.name;

            return(View(filter));
        }
Exemple #4
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)));
        }
Exemple #5
0
        //public string Binding()
        //{
        //    //kamus
        //    GridRequestParameters param = GridRequestParameters.Current;
        //    List<rent> items = null;

        //    //algoritma
        //    Guid idOwner = (Guid)(User as CustomPrincipal).IdOwner;
        //    DateTime start = DateTime.Parse("2016-01-01");
        //    DateTime finish = DateTime.Parse("2016-01-10");
        //    items = RepoRent.FindAll(idOwner, start, finish);

        //    return new JavaScriptSerializer().Serialize(new BookingPresentationStub().MapList(items));
        //}

        public JsonResult Binding()
        {
            //kamus
            GridRequestParameters param = GridRequestParameters.Current;
            Guid idOwner = (Guid)(User as CustomPrincipal).IdOwner;

            List <rent>      rents;
            List <car>       cars;
            List <car_model> carModels = new List <car_model>();

            DailyFilterModel fm = ParseFilterInfo(param.Filters);
            List <BookingPresentationStub> result = new List <BookingPresentationStub>();

            Business.Infrastructure.FilterInfo filters;
            List <string>           carModel = new List <string>();
            BookingPresentationStub child;
            List <Guid>             carsId;

            DateTime       dtStart, dtEnd;
            DateTimeOffset dtoStart, dtoEnd;

            //algoritma
            dtStart  = new DateTime(fm.StartDate.Year, fm.StartDate.Month, fm.StartDate.Day, fm.StartDate.Hour, fm.StartDate.Minute, fm.StartDate.Second);
            dtStart  = DateTime.SpecifyKind(dtStart, DateTimeKind.Local);
            dtoStart = dtStart;

            dtEnd  = new DateTime(fm.EndDate.Year, fm.EndDate.Month, fm.EndDate.Day, fm.EndDate.Hour, fm.EndDate.Minute, fm.EndDate.Second);
            dtEnd  = DateTime.SpecifyKind(dtEnd, DateTimeKind.Local);
            dtoEnd = dtEnd;

            rents = RepoRent.FindAll(idOwner, fm.StartDate, fm.EndDate);

            //menambahkan filter terkait CarModelName
            filters = new Business.Infrastructure.FilterInfo
            {
                Filters = new List <Business.Infrastructure.FilterInfo>
                {
                    new Business.Infrastructure.FilterInfo {
                        Field = "id_owner", Operator = "eq", Value = idOwner.ToString()
                    },
                    new Business.Infrastructure.FilterInfo {
                        Field = "car_model.name", Operator = "eq", Value = fm.CarModelName
                    },
                    new Business.Infrastructure.FilterInfo {
                        Field = "is_active", Operator = "eq", Value = true.ToString()
                    },
                },
                Logic = "and"
            };
            cars   = RepoCar.FindAll(null, null, null, filters);
            carsId = cars.Select(m => m.id).ToList();

            rents = rents.Where(m => m.id_car != null && carsId.Contains(m.id_car.Value)).ToList();
            foreach (rent r in rents)
            {
                child = new BookingPresentationStub(r);

                result.Add(child);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #6
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));
            }
        }
Exemple #7
0
        public ActionResult Index()
        {
            DailyFilterModel filter = new DailyFilterModel();

            return(View(filter));
        }