Beispiel #1
0
 public async Task<ActionResult> Estimate(BillingModule.BillingNOC noc) {
   var BillingGroupID = Util.GetBillingGroupID();
   BillingModule.BillingGroup group = new BillingModule.BillingGroup(BillingGroupID);
   await noc.GenerateFields();
   var Billing = await group.GenerateEstimate(noc);
   return Json(Billing, JsonRequestBehavior.AllowGet);
 }
Beispiel #2
0
    public async Task<ActionResult> FlightReport([Bind(Prefix = "ID")]int FlightID = 0) {
      // if (!exLogic.User.hasAccess("FLIGHT.MAP")) return RedirectToAction("NoAccess", "Home");
      ViewBag.FlightID = FlightID;

      var FlightData = await (
        from n in db.DroneFlight
        where n.ID == FlightID
        select new FlightViewModel {
          ID = n.ID,
          PilotID = n.PilotID,
          GSCID = n.GSCID,
          FlightDate = n.FlightDate,
          FlightHours = n.FlightHours,
          FlightDistance = n.FlightDistance,
          DroneID = n.DroneID,
          CreatedOn = n.CreatedOn,
          ApprovalID = n.ApprovalID
        }).FirstOrDefaultAsync();
      if (FlightData == null)
        return HttpNotFound();

      if (FlightData.FlightHours == null)
        FlightData.FlightHours = 0;
      FlightData.PilotName = await (
        from n in db.MSTR_User
        where n.UserId == FlightData.PilotID
        select n.FirstName + " " + n.LastName).FirstOrDefaultAsync();

      FlightData.GSCName = await (
        from n in db.MSTR_User
        where n.UserId == FlightData.GSCID
        select n.FirstName + " " + n.LastName).FirstOrDefaultAsync();

      FlightData.DroneName = await (
        from n in db.MSTR_Drone
        where n.DroneId == FlightData.DroneID
        select n.DroneName).FirstOrDefaultAsync();

      FlightData.PortalAlerts = await (
        from n in db.PortalAlerts
        where n.FlightID == FlightID
        select n).ToListAsync();


      var thisApproval =
        from n in db.GCA_Approval
        where n.ApprovalID == FlightData.ApprovalID
        select n;
      FlightData.Approval = await thisApproval.FirstOrDefaultAsync();

      //set Alert message for Report
      //setReportMessages(FlightData.PortalAlerts, FlightData.Approval);

      FlightData.MapData = await (
        from n in db.FlightMapDatas
        where n.FlightID == FlightID
        orderby n.FlightMapDataID
        select new LatLng{
          Lat = (Decimal)n.Latitude,
          Lng =(Decimal)n.Longitude
          }
        ).ToListAsync();

      FlightData.Videos = await (
        from n in db.DroneFlightVideos
        where n.FlightID == FlightID
        select n)
        .OrderBy(o => o.CreatedDate)
        .ToListAsync();


      FlightData.Approvals = await (
        from n in db.GCA_Approval
        where FlightData.FlightDate >= n.StartDate &&
              FlightData.FlightDate <= n.EndDate &&
              n.DroneID == FlightData.DroneID
        select n
      ).ToListAsync();

      FlightData.Info = await (
        from n in db.FlightInfoes
        where n.FlightID == FlightID
        select n).FirstOrDefaultAsync();
      if(FlightData.Info == null) {
        FlightData.Info = new Models.FlightInfo();
        LatLng FirstPoint = FlightData.MapData.FirstOrDefault();
        Exponent.WeatherAPI ReportWeather = new Exponent.WeatherAPI();      
        Exponent.WeatherForcast Condition = ReportWeather.GetByLocation((Double)FirstPoint.Lat, (Double)FirstPoint.Lng);
        FlightData.Info.Condition = Condition.Today.ConditionText;
        FlightData.Info.WindSpeed = Condition.Today.WindSpeed.ToString("0.0");
        FlightData.Info.Humidity = Condition.Today.Humidity.ToString("0");
        FlightData.Info.Visibility = (Decimal)Condition.Today.Visibility;
        FlightData.Info.Pressure = (Decimal)Condition.Today.Pressure;
        FlightData.Info.Temperature = Condition.Today.Temperature.ToString("0.0");
      }


      //Billing 
      int BillingGroupID = 1;
      BillingModule.BillingGroup grp = new BillingModule.BillingGroup(BillingGroupID);
      BillingModule.BillingNOC noc = new BillingModule.BillingNOC();
      Models.DroneFlight flight = await noc.LoadNocForFlight(FlightID);
      //await noc.GenerateFields();
      FlightData.Billing = await grp.GenerateBilling(noc, flight);


      return View(FlightData);
    }