public IActionResult Index() { var homeVM = new HomeViewModel() { CarMarkCount = _carMarkRepository.Count(x => true), CustomerCount = _customerRepository.Count(x => true), CarCount = _carRepository.Count(x => true), LendCarCount = _carRepository.Count(x => x.Borrower != null) }; return(View(homeVM)); }
public IActionResult Index() { var model = new HomeViewModel(); model.CarCount = _carModel.Count(); model.ShowroomCount = _showroomModel.Count(); model.UserCount = 1; return(View(model)); }
//adanya idCar bakal bikin aneh fungsi kalau dipanggil untuk kendo grid public string Binding(Guid?idCar) { //kamus GridRequestParameters param = GridRequestParameters.Current; car car; Business.Infrastructure.FilterInfo filters; Guid?idCarModel; //algoritma if (param.Filters.Filters == null) { param.Filters.Filters = new List <Business.Infrastructure.FilterInfo>(); param.Filters.Logic = "and"; } param.Filters.Filters.Add(new Business.Infrastructure.FilterInfo { Field = "id_owner", Operator = "eq", Value = GetOwnerId().ToString() }); List <car> items = RepoCar.FindAll(param.Skip, param.Take, (param.Sortings != null ? param.Sortings.ToList() : null), param.Filters); int total = RepoCar.Count(param.Filters); if (idCar != null) { car = RepoCar.FindByPk(idCar.Value); if (car != null) { filters = param.Filters.Filters.Where(m => m.Field == "id_car_model").FirstOrDefault(); if (filters == null) //menambahkan mobil jika car_model sama dengan param { items.Add(car); ++total; } else { idCarModel = Guid.Parse(filters.Value); if (car.id_car_model == idCarModel) { items.Add(car); ++total; } } } } return(new JavaScriptSerializer().Serialize(new { total = total, data = new CarPresentationStub().MapList(items) })); }
public IActionResult List() { var customerVM = new List <CustomerViewModel>(); var customers = _customerRepository.GetAll(); if (customers.Count() == 0) { return(View("Empty")); } foreach (var customer in customers) { customerVM.Add(new CustomerViewModel { Customer = customer, CarCount = _carRepository.Count(a => a.BorrowerId == customer.CustomerId) }); } return(View(customerVM)); }
private List <ChartAttribute> GenerateReport(List <rent> items, DateTime start, DateTime finish) { //kamus List <ChartAttribute> result = new List <ChartAttribute>(); ChartAttribute oneMonthData; List <rent> rentsPerMonth, rentsPerDay; int totalUsage; double utilization; List <Guid> carInOneDay; int ownerCarsCount; DateTime iteration; int daysInMonth; DateTime dtStartMonth, dtEndMonth, dtStartDay, dtEndDay; DateTimeOffset dtoStartMonth, dtoEndMonth, dtoStartDay, dtoEndDay; Guid? idOwner = (User as CustomPrincipal).IdOwner; //algoritma //Business.Infrastructure.FilterInfo filters = new Business.Infrastructure.FilterInfo { Field = "id_owner", Operator = "eq", Value = idOwner.ToString() }; // fungsi semacam where Business.Infrastructure.FilterInfo filters = new Business.Infrastructure.FilterInfo(); if (filters.Filters == null) { filters.Filters = new List <Business.Infrastructure.FilterInfo>(); filters.Logic = "and"; } filters.Filters.Add(new Business.Infrastructure.FilterInfo { Field = "id_owner", Operator = "eq", Value = idOwner.ToString() }); filters.Filters.Add(new Business.Infrastructure.FilterInfo { Field = "is_active", Operator = "eq", Value = true.ToString() }); ownerCarsCount = RepoCar.Count(filters); iteration = new DateTime(start.Year, start.Month, 1); finish = new DateTime(finish.Year, finish.Month, 1); while (iteration <= finish) { //koding //List<rent> tempRent = items.Where(n => (n.start_rent <= iteration && n.finish_rent >= iteration) || (n.start_rent >= start && n.start_rent <= finish)).ToList(); oneMonthData = new ChartAttribute(); totalUsage = 0; utilization = 0; //mengecek hari dalam sebulan daysInMonth = System.DateTime.DaysInMonth(iteration.Year, iteration.Month); //mengambil data rent dalam 1 bulan dtStartMonth = new DateTime(iteration.Year, iteration.Month, 1, 0, 0, 0); dtStartMonth = DateTime.SpecifyKind(dtStartMonth, DateTimeKind.Local); dtoStartMonth = dtStartMonth; dtEndMonth = new DateTime(iteration.Year, iteration.Month, DateTime.DaysInMonth(iteration.Year, iteration.Month), 23, 59, 59); dtEndMonth = DateTime.SpecifyKind(dtEndMonth, DateTimeKind.Local); dtoEndMonth = dtEndMonth; rentsPerMonth = items.Where(n => (n.start_rent <= dtoStartMonth && n.finish_rent >= dtoStartMonth) || (n.start_rent <= dtoEndMonth && n.finish_rent >= dtoEndMonth) || (n.start_rent >= dtoStartMonth && n.finish_rent <= dtoEndMonth) || (n.start_rent <= dtoStartMonth && n.finish_rent >= dtoEndMonth) ).ToList(); //iteration for eachday for (int j = 1; j <= daysInMonth; j++) { //DateTime dateStartTemp = new DateTime(iteration.Year, iteration.Month, j); //DateTime dateFinishTemp = new DateTime(iteration.Year, iteration.Month, j); //rentPerDay = rentPerMonth.Where(n => (n.start_rent <= dateStartTemp && n.finish_rent >= dateStartTemp) || (n.start_rent >= dateStartTemp && n.finish_rent <= dateFinishTemp) || (n.finish_rent >= dateStartTemp && n.finish_rent <= dateFinishTemp) || (n.start_rent.Day <= dateStartTemp.Day && n.finish_rent.Day >= dateStartTemp.Day) || (n.start_rent.Day >= dateStartTemp.Day && n.finish_rent.Day <= dateFinishTemp.Day) || (n.finish_rent.Day >= dateStartTemp.Day && n.finish_rent.Day <= dateFinishTemp.Day) || (n.start_rent.Day <= dateStartTemp.Day && n.finish_rent.Day >= dateStartTemp.Day && n.start_rent.Month <= dateStartTemp.Month && n.finish_rent.Month >= dateStartTemp.Month) || (n.start_rent.Day >= dateStartTemp.Day && n.finish_rent.Day <= dateFinishTemp.Day && n.start_rent.Month >= dateStartTemp.Month && n.finish_rent.Month <= dateFinishTemp.Month) || (n.finish_rent.Day >= dateStartTemp.Day && n.finish_rent.Day <= dateFinishTemp.Day && n.finish_rent.Day >= dateStartTemp.Day && n.finish_rent.Month <= dateFinishTemp.Month) || (n.start_rent <= dateStartTemp && n.start_rent <= dateFinishTemp)).ToList(); //rentPerDay = rentPerMonth.Where(n => (n.start_rent <= dateStartTemp && n.finish_rent >= dateStartTemp) || (n.start_rent >= dateStartTemp && n.finish_rent <= dateFinishTemp) || (n.finish_rent >= dateStartTemp && n.finish_rent <= dateFinishTemp) || (n.start_rent.Day <= dateStartTemp.Day && n.finish_rent.Day >= dateStartTemp.Day) || (n.start_rent.Day >= dateStartTemp.Day && n.finish_rent.Day <= dateFinishTemp.Day) || (n.finish_rent.Day >= dateStartTemp.Day && n.finish_rent.Day <= dateFinishTemp.Day)).ToList(); //List<rent> daysMonth = tempRent.Where(tempRent.GetRange().ToList(); //rentsPerDay = rentsPerMonth.Where(n => // (n.start_rent <= dateStartTemp && n.finish_rent >= dateFinishTemp) || // (n.start_rent >= dateStartTemp && n.start_rent <= dateFinishTemp) || // (n.finish_rent >= dateStartTemp && n.finish_rent <= dateFinishTemp) || // (n.start_rent.Day <= dateStartTemp.Day && n.finish_rent.Day >= dateStartTemp.Day) || // (n.start_rent.Day >= dateStartTemp.Day && n.finish_rent.Day <= dateFinishTemp.Day) || // (n.finish_rent.Day >= dateStartTemp.Day && n.finish_rent.Day <= dateFinishTemp.Day) //).ToList(); dtStartDay = new DateTime(iteration.Year, iteration.Month, j, 0, 0, 0); dtStartDay = DateTime.SpecifyKind(dtStartDay, DateTimeKind.Local); dtoStartDay = dtStartDay; dtEndDay = new DateTime(iteration.Year, iteration.Month, j, 23, 59, 59); dtEndDay = DateTime.SpecifyKind(dtEndDay, DateTimeKind.Local); dtoEndDay = dtEndDay; rentsPerDay = rentsPerMonth.Where(n => (n.start_rent <= dtoStartDay && n.finish_rent >= dtoStartDay) || (n.start_rent <= dtoEndDay && n.finish_rent >= dtoEndDay) || (n.start_rent >= dtoStartDay && n.finish_rent <= dtoEndDay) || (n.start_rent <= dtoStartDay && n.finish_rent >= dtoEndDay) ).ToList(); carInOneDay = new List <Guid>(); foreach (rent r in rentsPerDay) { if (r.id_car.HasValue) { if (!carInOneDay.Contains(r.id_car.Value)) { ++totalUsage; carInOneDay.Add(r.id_car.Value); } } } } utilization = ((double)(totalUsage * 100)) / ((double)(daysInMonth * ownerCarsCount)); oneMonthData.Value = utilization; oneMonthData.Category = new DateTime(iteration.Year, iteration.Month, 1); result.Add(oneMonthData); iteration = iteration.AddMonths(1); } return(result); }
public int Count() { return(_carRepository.Count()); }