public ActionResult AddNewPosting(NewPostingViewModel viewModel) { TripRepository tripRepository = new TripRepository(); tripRepository.AddTrip(viewModel, UserAccountsManager.Instance.CurrentUser); return(RedirectToAction("Index")); }
public static void SendRapport(int inCons, int inDest, DateTime inStart) { var xmlList = Serializer.Load(); for (int i = 0; i < xmlList.Count; i++) { if (xmlList[i].myTrip.User == inCons && xmlList[i].myTrip.Destination == inDest && xmlList[i].myTrip.Start == inStart) { FullTrip full = xmlList[i]; Trip trip = ModelTransformer.TripModel2Trip(full.myTrip); TripRepository.AddTrip(trip); foreach (var vac in full.myVacation) { vac.tripID = trip.tripID; VacationsRepository.AddVacation(ModelTransformer.VacationModel2Vacation(vac)); } foreach (var item in full.myVerifications) { item.tripID = trip.tripID; VerificationRepository.AddVerification(ModelTransformer.VerificationModel2Verification(item)); } xmlList.RemoveAt(i); } } Serializer.Overwrite(xmlList); }
public async void BtnPostTrip_Clicked(object sender, EventArgs e) { try { using (TripRepository tripRepository = new TripRepository()) { if (IsValidForm()) { var result = await DisplayAlert("Warning", "Are you sure ?", "Yes", "No"); if (result) { EnableDisableActivityIndicator(true); EnableDisableControls(false); var trip = new Trip { TripId = Guid.NewGuid().ToString(), Driver = _driver, TripRoute = new TripRoute { MeetingPointLongitude = route.MeetingPoint.Position.Longitude, MeetingPoitnLatitude = route.MeetingPoint.Position.Latitude, MeetingPoitnAddress = route.MeetingPoint.Address, TargetPointLongitude = route.TargetPoint.Position.Longitude, TargetPointLatitude = route.TargetPoint.Position.Latitude, TargetPoitnAddress = route.TargetPoint.Address }, MeetingTime = tpMeetingTime.Time.ToString(), TimestampMeetingDate = Util.SetMeetingDate(tpMeetingTime.Time.ToString()), MeetingDate = Util.FormatMeetingDate(tpMeetingTime.Time.ToString()), Price = Convert.ToDecimal(txtPrice.Text), SeatsAvailables = Convert.ToInt16(txtSeatsAvailables.Text), State = "Posted" }; await tripRepository.AddTrip(trip); EnableDisableActivityIndicator(false); await DisplayAlert("Info", "Route posted successfully", "Ok"); workingPointFlag = string.Empty; RemovePoint(); CleanEntries(); EnableDisableControls(true); await Navigation.PushAsync(new TripWaitingRoomPage(trip)); } } } } catch { EnableDisableActivityIndicator(false); await DisplayAlert("Error", "An unexpected error has occurred", "Ok"); } }
public int CreateTrip(int passportCode, string address) { var client = GetClient(passportCode); var trip = new Trip() { Client = client, Address = address, status = TripStatus.Created }; return(tripRepository.AddTrip(trip)); }
static void Main(string[] args) { //Currency Test CurrencyRepository currencyRepo = new CurrencyRepository(); Currency EUR = currencyRepo.GetCurrencyWithName("EUR"); //Trip Test PersonRepository repo = new PersonRepository(); repo.AddPerson("Pieter"); repo.AddPerson("Margaux"); Person Pieter = repo.GetPerson(0); Person Margaux = repo.GetPerson(1); TripRepository tripRepo = new TripRepository(); tripRepo.AddTrip("Parijs", EUR); Trip Parijs = tripRepo.GetTrip(0); Parijs.AddPersonToTrip(Pieter); Parijs.AddPersonToTrip(Margaux); // "m" == decimal number Expense Resto = new Expense(Pieter, Parijs, EUR); Resto.AddItem("Pasta", 8.05m, Pieter); Resto.AddItem("Pasta", 8.05m, Margaux); Resto.AddItem("Wine", 8.05m, Margaux); Resto.AddItem("Ice cream", 5.00m, Margaux); Parijs.AddExpenseToTrip(Resto); Expense Museum = new Expense(Margaux, Parijs, EUR); Museum.AddItem("Entry", 12m, Pieter); Museum.AddItem("Entry", 12m, Margaux); Parijs.AddExpenseToTrip(Museum); Pieter.AddTransaction(Margaux, 2); var owes = Pieter.GetOwesPersonInCurrency(currencyRepo.GetCurrencyWithName("EUR")); Console.WriteLine(""); }
public void SubmitTrip() { string locationName = TripLocationName.text; TripRepository repo = GetComponent <TripRepository>(); CurrencyRepository currencyRepo = GetComponent <CurrencyRepository>(); CurrencyDropDown dropDown = GetComponent <CurrencyDropDown>(); Currency currency = currencyRepo.GetCurrencyWithName(dropDown.selectedCurrency); repo.AddTrip(locationName, currency); tripElementList = GetComponent <TripElementList>(); tripElementList.Prime(); TripLocationName.text = ""; InvalidTripLocationName.text = ""; submitButton.interactable = false; }
public static void AddTrip(TripModel trip) { //överför modellen TripModell till ett objekt av databastypen Trip var newTrip = new Trip(); newTrip.origin = trip.Origin; newTrip.destination = trip.Destination; newTrip.start = trip.Start; newTrip.end = trip.End; newTrip.prepayment = trip.Prepayment; newTrip.note = trip.Note; newTrip.user = trip.User; newTrip.boss = trip.BossId; newTrip.approved = trip.Status; //för in datan i databasen TripRepository.AddTrip(newTrip); }
protected void btn_SubmitTrip_Click(object sender, EventArgs e) { try { if (!this.IsValid) { return; } long _driverID = 0; long?CodriverID = null; long vehicleId = 0; long vehicleTypeId = 0; if (cboVehiclesType.SelectedIndex > 0) { vehicleTypeId = Convert.ToInt64(cboVehiclesType.SelectedValue); } //var card = new GarageCardRepository().GetCard(txtBoxBnkCard.Text); //if (card != null) //{ // CardCID = card.GarageCardId; //} if (driverDD.SelectedIndex > 0) { _driverID = Convert.ToInt64(driverDD.SelectedValue); } if (coDriverDD.SelectedIndex > 0) { CodriverID = Convert.ToInt64(coDriverDD.SelectedValue); } //if (RESPCdeDD.SelectedIndex > 0) //{ // RESPCodeID = Convert.ToInt32(RESPCdeDD.SelectedValue); //} long tripId = 0; if (this.Mode == OperationMode.Add) { tripId = m_Repository.AddTrip(vehicleId, _driverID, CodriverID, tripDescpText.Text, ProJTxt.Text, DateTime.ParseExact(_tripDate.Text, "dd/MM/yyyy", null), DateTime.ParseExact(returnDate.Text, "dd/MM/yyyy", null), this.UserName, startPoint.Text, destination.Text, vehicleTypeId); string body = string.Format("Dear {0} \r\n\r\nThere is a trip request waiting to your athorisation. Kindly logon to vehicle management system to authorise the trip. \r\n\r\nRegards", this.ManagerName); var success = new EmailRepository().SendEmail(this.ManagerAddress, this.ManagerName, "Trip request for authorisation", body); } else { if (!long.TryParse(this.RedirectId, out tripId)) { this.RedirectPage(Pages.TRIP_CLOSURE); return; } m_Repository.UpdateTrip(tripId, vehicleId, _driverID, CodriverID, tripDescpText.Text, ProJTxt.Text, DateTime.ParseExact(_tripDate.Text, "dd/MM/yyyy", null), DateTime.ParseExact(returnDate.Text, "dd/MM/yyyy", null), this.UserName, startPoint.Text, destination.Text, vehicleTypeId); } this.RedirectPage(Pages.TRIP_PASSENGERS, tripId.ToString()); } catch (Exception ex) { this.HandleException(ex); } }