public static async Task <VehicleReport> Report(ReportVehicleRequest reportVehicle) { if (reportVehicle == null) { throw new AppArgumentException(nameof(reportVehicle)); } if (string.IsNullOrWhiteSpace(reportVehicle.Plate)) { throw new AppArgumentException(nameof(reportVehicle.Plate)); } if (reportVehicle.CommunityId == null || reportVehicle.CommunityId == Guid.Empty) { throw new AppArgumentException(nameof(reportVehicle.CommunityId)); } if (reportVehicle.UserId == null || reportVehicle.UserId == Guid.Empty) { throw new AppArgumentException(nameof(reportVehicle.UserId)); } var vehicleReport = Entities.VehicleReport.From(reportVehicle.Plate, reportVehicle.CommunityId.Value, reportVehicle.UserId.Value); var inserted = await Context.VehicleReportGateway.InsertPlateReport(vehicleReport); return(VehicleReport.From(inserted.VehicleReportId)); }
public static List <VehicleReport> GetVehicleReport(DateTime dateFrom, DateTime dateTo) { MySqlCommand cmd = new MySqlCommand("GetVehicleReport", new MySqlConnection(connectionString)); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new MySqlParameter(("_dateFrom"), dateFrom)); cmd.Parameters.Add(new MySqlParameter(("_dateTo"), dateTo)); cmd.Connection.Open(); MySqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); List <VehicleReport> vehicleReports = new List <VehicleReport>(); while (rdr.Read()) { VehicleReport vehicleReport = new VehicleReport(); vehicleReport.vehicleRegistration = rdr[0].ToString(); vehicleReport.vehicleBrand = rdr[1].ToString(); vehicleReport.vehicleModel = rdr[2].ToString(); vehicleReport.fuelConsumption = double.Parse(rdr[3].ToString()); vehicleReport.totalDistance = double.Parse(rdr[4].ToString()); vehicleReports.Add(vehicleReport); } rdr.Close(); return(vehicleReports); }
public async Task <VehicleReport> InsertPlateReport(VehicleReport vehicleReport) { _plateReportRepository.Create(vehicleReport); _plateReportRepository.SaveChanges(); return(await Task.FromResult(vehicleReport) .ConfigureAwait(true)); }
public Task <VehicleReport> InsertPlateReport(VehicleReport vehicleReport) { return(Task.FromResult(new VehicleReport() { VehicleReportId = vehicleReport.VehicleReportId, Plate = vehicleReport.Plate })); }
public ActionResult Manage() { //find user var user = db.Users.Find(User.Identity.GetUserId()); VehicleModelView vehicleModel = new VehicleModelView(); if (db.Vehicles.Count() > 0) { //chart data vehicleModel.vehicles = db.Vehicles .OrderByDescending(x => x.Added) .Where(x => x.Dealer.Id == user.Id) .ToList(); vehicleModel.vehicleReports = new List <VehicleReport>(); //get booking data foreach (var v in vehicleModel.vehicles) { //find bookings var booking = db.Bookings.Include(x => x.Reciept).FirstOrDefault(x => x.vehicle.Id == v.Id); //get booking deatails VehicleReport report = new VehicleReport(); try { report.vehicleName = v.make + " " + v.model; report.TotalCharge = booking.Reciept.TotalCharges; report.NumberOfDays = booking.NumberOfDays; } catch (NullReferenceException) { report.TotalCharge = 0.1; report.NumberOfDays = 0; } vehicleModel.vehicleReports.Add(report); } VehicleReport report2 = new VehicleReport(); ViewBag.earnings = report2.Earnings(vehicleModel.vehicles.ToList()); return(View(vehicleModel)); } return(View()); }