//private void AddJobtoLimoAnyWhere() //{ //// JobWrapper jobWrapper = new JobWrapper(); //// string apiId = ConfigurationSettings.AppSettings["apiId"]; //Your Api ID //// string apiKey = ConfigurationSettings.AppSettings["apiKey"]; //Your Api Key //} private Job SaveJobInDatabase(string tripConfirmationNumber, string authorizationCode, string invoiceNumber) { LimoEntitiesEntityFremwork limoEntity = new LimoEntitiesEntityFremwork(); JobWrapper jobWrapper = new JobWrapper(); Job job = new Job(); job.CompanyCarID = jobWrapper.JobDetailsObject.CarID; job.UserID = jobWrapper.UserNumber > 0 ? jobWrapper.UserNumber : new int?(); //.JobDetailsObject.userID; job.FromAddress = jobWrapper.JobDetailsObject.FromAddress; job.ToAddress = jobWrapper.JobDetailsObject.ToAddress; job.CityID = jobWrapper.JobDetailsObject.cityID; job.JobDate = jobWrapper.JobDetailsObject.JobDate; job.JobTime = jobWrapper.JobDetailsObject.JobMappedTime; job.TotalPrice = jobWrapper.JobDetailsObject.JobTotalPrise; job.EstimatedFarePrice = jobWrapper.JobDetailsObject.JobBasePrise; job.GratuityPrice = jobWrapper.JobDetailsObject.JobGratuity; job.ProcessingFee = jobWrapper.JobDetailsObject.JobProcessingFees; job.Taxes = jobWrapper.JobDetailsObject.JobStateTaxes; job.FirstName = txtFirstName.Text; job.LastName = txtLastName.Text; job.ComapnyConfirmNum = tripConfirmationNumber; job.AuthorizationCode = authorizationCode; job.AuthorizInvoiceNumber = invoiceNumber; DAL.User user = limoEntity.Users.Where(obj => obj.UserID == jobWrapper.UserNumber).FirstOrDefault(); if (user != null) { user.CardZipCode = txtZipCode.Text; user.CardNumber = txtCardNumber.Text; user.CardAddress = txtAdddress.Text; user.CardStateID = ddlState.SelectedValue; user.CardExpirationDate = ddlExpirationMonth.SelectedValue + "/" + ddlExpirationYear.SelectedValue; user.CardHolderFName = txtFirstName.Text; user.CardHolderLName = txtLastName.Text; } //job.OtherPrice = jobWrapper.JobDetailsObject.otherPrice; if (limoEntity.JobStatus != null) { string pending = Limo_Gloabel.JobStatus.Pending.ToString().ToLower(); DAL.JobStatu jobStatus = limoEntity.JobStatus.Where(obj => obj.JobStatus.ToLower() == pending).FirstOrDefault(); if (jobStatus != null) { job.JobStatusID = jobStatus.JobStatusID; } } int idTemp = jobWrapper.JobDetailsObject != null? jobWrapper.JobDetailsObject.CarID: 0; var car = limoEntity.Cars.Where(xxx => xxx.CarID == idTemp). FirstOrDefault(); int driverID = 0; if (car != null) { driverID = car.Drivers != null?car.Drivers.ToList()[0].DriverID : 0; //if (driverID > 0) //job.DriverID = driverID; } job.JobBy = 1; job.NoPassenger = int.Parse(jobWrapper.JobDetailsObject.UserNumber); job.FromLat = jobWrapper.JobDetailsObject.FromAddressLat; job.FromLng = jobWrapper.JobDetailsObject.FromAddressLNG; job.ToLat = jobWrapper.JobDetailsObject.ToAddressLat; job.ToLng = jobWrapper.JobDetailsObject.ToAddressLNG; limoEntity.Jobs.AddObject(job); limoEntity.SaveChanges(); try { if (driverID > 0) { //Service1.LimoAllOver ccc = new Service1.LimoAllOver(); MobileService.LimoAllOver ccc = new MobileService.LimoAllOver(); //ccc.SendNotifcationToDriver("android", driverID); ccc.SendJobToDriver(driverID, job.JobID); } } catch (Exception) { } if (string.IsNullOrEmpty(job.ComapnyConfirmNum)) { job.ComapnyConfirmNum = job.JobID.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString().Substring(2); } job.LimoConfirmNumber = "L" + job.JobID.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString().Substring(2); limoEntity.SaveChanges(); return(job); }
private void ProcessDespatchData() { if (!string.IsNullOrEmpty(hfLAtLng.Value) && !string.IsNullOrEmpty(hfLAtLngTo.Value)) { var tempLatLng = hfLAtLng.Value.Split(','); var lat = tempLatLng[0]; var lng = tempLatLng[1]; var tempLatLngTo = hfLAtLngTo.Value.Split(','); var latTo = tempLatLngTo[0]; var lngTo = tempLatLngTo[1]; JobWrapper jobWrapper = new JobWrapper(); if (hfDistance.Value != null) { if (hfDistance.Value == "-1" || string.IsNullOrEmpty(hfDistance.Value)) { string message = "Google Map could not be created for the entered parameters. Please be specific while providing the destination location."; string script = "alert('" + message + "');"; ScriptManager.RegisterClientScriptBlock(this, GetType(), "alert", script, true); } else if (!IsValidDate) { string message = " Invalid Date / Time."; string script = "alert('" + message + "');"; ScriptManager.RegisterClientScriptBlock(this, GetType(), "alert", script, true); } else { double temp = 0, duration = 1; double minMile = double.Parse(ConfigurationSettings.AppSettings["MinMile"]); double.TryParse(hfDistance.Value, out temp); temp = temp == 0 || temp < minMile ? minMile : temp; string[] arrTemp = hfDuration.Value.Split(' '); if (arrTemp.Length == 4) { duration = (double.Parse(arrTemp[0])) * 60 + double.Parse(arrTemp[2]); } else if (arrTemp.Length == 2) { double.TryParse(hfDuration.Value.Split(' ')[0], out duration); } duration = duration * 1 / 60; duration = duration <= 1 ? 1 : duration <= 2 ? 2 : duration; try { AddJobtoLimoAnyWhere(); } catch (Exception) { } LimoEntitiesEntityFremwork limoEntity = new LimoEntitiesEntityFremwork(); Job job = new Job(); job.FromAddress = txtSource.Text; // +", NEW YORK, NY, USA"; job.ToAddress = txtDistenation.Text; // +", NEW YORK, NY, USA"; job.JobDate = DateTime.Parse(txtDatepicker.Text); //job.NOUsers = int.Parse(ddlNOPassenger.SelectedValue); job.JobTime = ddlHour.SelectedItem.Text.Substring(0, 2) + ddlMinutes.SelectedItem.Text + ddlHour.SelectedItem.Text.Substring(2); double price = 0; double.TryParse(txtTotalPrice.Text, out price); job.TotalPrice = price; job.FirstName = txtFirstName.Text; job.LastName = txtLastName.Text; job.Email = txtPassEmail.Text; job.Mobile = txtPassMobile.Text; string pending = Limo_Gloabel.JobStatus.Pending.ToString().ToLower(); DAL.JobStatu jobStatus = limoEntity.JobStatus.Where(obj => obj.JobStatus.ToLower() == pending).FirstOrDefault(); if (jobStatus != null) { job.JobStatusID = jobStatus.JobStatusID; } job.IsDespath = true; job.JobBy = 1; var noPass = ddlNOPassenger.SelectedItem.Text; if (noPass.StartsWith("0")) { noPass = noPass.Remove(0, 1); } job.NoPassenger = int.Parse(noPass); if (CorPorateID > 0) { job.CorporateID = CorPorateID; } job.FromLat = lat; job.FromLng = lng; job.ToLat = latTo; job.ToLng = lngTo; job.Notes = txtNote.Text; limoEntity.Jobs.AddObject(job); limoEntity.SaveChanges(); job.ComapnyConfirmNum = job.JobID.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString().Substring(2); job.LimoConfirmNumber = "L" + job.JobID.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString().Substring(2); limoEntity.SaveChanges(); //Service1.LimoAllOver ccc = new Service1.LimoAllOver(); MobileService.LimoAllOver ccc = new MobileService.LimoAllOver(); ccc.GetDriversNearMe(lng, lat, "1", job.JobID); Response.Redirect("~/Admin/Pages/Despatch.aspx"); } } } }