예제 #1
0
        public ActionResult ExportToExcel(SearchReportViewModel vm)
        {
            ReportModel rm          = new ReportModel();
            var         report      = rm.GetVesselReports(vm, false);
            string      dateTimeNow = DateTime.Now.ToString("yyyyMMddHHmm");

            return(new XlsFileResult <ReportDto>(report, string.Format("report_{0}.xls", dateTimeNow)));
        }
예제 #2
0
        public ActionResult Index()
        {
            SearchReportViewModel vm        = new SearchReportViewModel();
            VesselService         vesselSvc = new VesselService();

            vm.Vessels = vesselSvc.GetVesselList();

            return(View(vm));
        }
예제 #3
0
 public PartialViewResult Index(SearchReportViewModel vm)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ReportModel rm      = new ReportModel();
             var         results = rm.GetVesselReports(vm, true);
             return(PartialView("Report", results));
         }
     }
     catch (Exception ex)
     {
     }
     return(PartialView("Report", new Core.DataTransferObjects.ReportDto()));
 }
예제 #4
0
        public ActionResult ExportToKml(SearchReportViewModel vm)
        {
            ReportModel rm     = new ReportModel();
            var         report = rm.GetVesselReports(vm, false);

            //convert to Placemark list
            double latitude;
            double longitude;
            var    loc = report.Select(s => new Placemark
            {
                Name        = s.IMO.ToString(),
                Description = "",
                Point       = new Location
                {
                    Latitude  = Double.TryParse(s.Lat, out latitude) ? latitude : 0,
                    Longitude = Double.TryParse(s.Lon, out longitude) ? longitude : 0
                }
            }).ToList();

            string dateTimeNow = DateTime.Now.ToString("yyyyMMddHHmm");

            return(new KmlFileResult(loc, string.Format("report_{0}.kml", dateTimeNow)));
        }
예제 #5
0
        public IActionResult OnGet(SearchReportViewModel search)
        {
            ReportsVM                = new ReportsViewModel();
            chartitems               = new List <Chart>();
            ViewData["plate"]        = search.plate;
            ViewData["model"]        = search.model;
            ViewData["username"]     = search.username;
            ViewData["initdate"]     = search.initdate;
            ViewData["enddate"]      = search.enddate;
            ViewData["invoicegraph"] = search.invoicegraph;

            //REPORT MOST POPULAR SERVICE BUYED
            var result1 = _db.ServiceDetails.GroupBy(x => x.ServiceTypeId).Select(g => new { key = g.Key, count = g.Count() }).OrderBy(x => x.count).Last();

            ReportsVM.mospopularservicename   = _db.ServiceDetails.Find(result1.key).ServiceName;
            ReportsVM.mostpopularservicecount = result1.count;

            //REPORT MOST VALUE CLIENT
            var result2 = _db.ServiceHeader.GroupBy(c => c.CarId).Select(a => new { carid = a.Key, suma = a.Sum(x => x.FullPrice) }).OrderBy(x => x.suma).Last();

            ReportsVM.mostvalueclientname  = _db.ApplicationUser.Find(_db.Car.Find(result2.carid).UserId).Name;
            ReportsVM.mostvalueclientmoney = result2.suma;

            ReportsVM.totaltoday = _db.ServiceHeader.Where(x => x.DateAdded.Date == DateTime.Now.Date).Sum(x => x.FullPrice);
            ReportsVM.totalmonth = _db.ServiceHeader.Where(x => x.DateAdded.Month == DateTime.Now.Month).Sum(x => x.FullPrice);


            chartitems.Add(DailyEarnings());
            chartitems.Add(ServicesGraph());
            chartitems.Add(FutureAppointments());


            ReportsVM.facturas = _db.ServiceHeader.ToList();
            foreach (var f in ReportsVM.facturas)
            {
                f.Car = _db.Car.Find(f.CarId);
                f.Car.ApplicationUser = _db.ApplicationUser.Find(f.Car.UserId);
            }


            if (search.plate != null)
            {
                ReportsVM.facturas = ReportsVM.facturas.Where(x => x.Car.VIN.Contains(search.plate)).ToList();
            }

            if (search.model != null)
            {
                ReportsVM.facturas = ReportsVM.facturas.Where(x => x.Car.Model.ToLower().Contains(search.model.ToLower())).ToList();
            }

            if (search.username != null)
            {
                ReportsVM.facturas = ReportsVM.facturas.Where(x => x.Car.ApplicationUser.Name.ToLower().Contains(search.username.ToLower())).ToList();
            }

            if (search.initdate != null)
            {
                ReportsVM.facturas = ReportsVM.facturas.Where(x => x.DateAdded >= DateTime.Parse(search.initdate)).ToList();
            }

            if (search.enddate != null)
            {
                ReportsVM.facturas = ReportsVM.facturas.Where(x => x.DateAdded <= DateTime.Parse(search.enddate).AddDays(1)).ToList();
            }

            int nmax = ReportsVM.facturas.Count > 10 ? 10 : ReportsVM.facturas.Count;

            if (search.maxrows != 0)
            {
                nmax = ReportsVM.facturas.Count > search.maxrows ? search.maxrows : ReportsVM.facturas.Count;
            }

            ReportsVM.facturas = ReportsVM.facturas.OrderByDescending(x => x.Id).ToList().GetRange(0, nmax);


            return(Page());
        }