public async Task <IActionResult> Put(int id, [FromBody] TripViewModel trip) { if (!ModelState.IsValid) { return(BadRequest()); } try { trip.Id = id; var user = await _userManager.FindByEmailAsync(User.Identity.Name); var roles = await _userManager.GetRolesAsync(user); if (trip.UserEmail != user.Email && !roles.Contains("admin")) { return(NotFound()); } var result = await _tripsWriteService.UpdateTripAsync(user, _mapper.Map <Trip>(trip)); if (result.Status == ResponseStatus.Unauthorized) { return(Unauthorized()); } if (result.Status == ResponseStatus.Failed) { return(BadRequest()); } return(Ok(_mapper.Map <TripViewModel>(result.Trip))); } catch (Exception) { return(BadRequest()); } }
public async Task <IActionResult> Post([FromBody] TripViewModel trip) { if (!ModelState.IsValid) { return(BadRequest()); } try { var user = await _userManager.FindByEmailAsync(User.Identity.Name); var mappedTrip = _mapper.Map <Trip>(trip); mappedTrip.TravelUserId = user.Id; var result = await _tripsWriteService.CreateTripAsync(user, mappedTrip); if (result.Status == ResponseStatus.Unauthorized) { return(Unauthorized()); } if (result.Status == ResponseStatus.Failed) { return(BadRequest()); } return(Ok(_mapper.Map <TripViewModel>(result.Trip))); } catch (Exception ex) { return(BadRequest(ex)); } }
public ViewResult Add(string id = "") { var vm = new TripViewModel(); if (id.ToLower() == "page2") { vm.PageNumber = 2; /******************************** * TODO - HOMEWORK * *******************************/ return(View("Add2", vm)); } else { vm.PageNumber = 1; /******************************** * TODO - HOMEWORK * *******************************/ return(View("Add1", vm)); } }
public ActionResult BataAdministratorUpdate(int id) { try { TripViewModel models = new TripViewModel(); Trip trip = _tripService.GetAllTripDetailsById(id); if (trip != null) { models = AutoMapper.Mapper.Map <TripViewModel>(trip); } models.Bata = GetBataData(); if (models.TripBata.Count > 0) { if (models.TripBata.LastOrDefault().IsDeleted.Equals(false)) { BataRate bata = _bataRateService.GetAllBataRates().Where(a => a.Description == models.TripBata.LastOrDefault().Description).LastOrDefault(); if (bata != null) { models.BataRateId = bata.BataId; models.BataRate = bata.Amount.ToString(); } } } return(View(models)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> GetById(int id) { try { var user = await _userManager.FindByEmailAsync(User.Identity.Name); var result = await _tripsReadService.GetTripById(user, id); if (result.Status == ResponseStatus.Unauthorized) { return(Unauthorized()); } if (result.Status == ResponseStatus.Failed) { return(BadRequest()); } TripViewModel Trip = _mapper.Map <TripViewModel>(result.Trip); var roles = await _userManager.GetRolesAsync(user); if (Trip.UserEmail != user.Email && !roles.Contains("admin")) { return(NotFound()); } return(Ok(Trip)); } catch (Exception ex) { return(BadRequest(ex)); } }
public async Task <IActionResult> Post([FromBody] TripViewModel tripViewModel) { try { if (ModelState.IsValid) { var trip = Mapper.Map <Trip>(tripViewModel); trip.UserName = User.Identity.Name; TravelRepository.AddTrip(trip); if (await TravelRepository.SaveChangesAsync()) { // Use map in case database modified the trip in any way. var value = Mapper.Map <TripViewModel>(trip); // todo|jdevl32: contant(s)... return(Created($"/api/trip/{value.Name}", value)); } // if } // if else if (HostingEnvironment.IsDevelopment()) { return(BadRequest(ModelState)); } // if } // try catch (Exception ex) { Logger.LogError($"Error adding trip ({tripViewModel}): {ex}"); } // catch return(BadRequest()); }
public static KeyValuePair <Trip, TripViewModel> AccessSourceManyNestedProperties() { var tripId = Guid.NewGuid(); var categoryId = Guid.NewGuid(); var catalogId = Guid.NewGuid(); var tripCatalog = new TripCatalog { Id = catalogId, Name = "Adventure - changed", }; var categoryTrip = new CategoryTrip { Id = categoryId, Name = "Asia - changed", Catalog = tripCatalog }; var trip = new Trip { Id = tripId, Name = "Fascinating family - changed", Category = categoryTrip }; var tripViewModel = new TripViewModel { Id = tripId }; return(new KeyValuePair <Trip, TripViewModel>(trip, tripViewModel)); }
public async Task <IActionResult> Post([FromBody] TripViewModel theTrip) { if (ModelState.IsValid) { //Save to the Database var newTrip = Mapper.Map <Trip>(theTrip); newTrip.UserName = User.Identity.Name; _repo.AddTrip(newTrip); if (await _repo.SaveChangesAsync()) { return(Created($"api/trips/{theTrip.Name}", Mapper.Map <TripViewModel>(newTrip))); } else { return(BadRequest("Failed to save the Trip!")); } } return(BadRequest(ModelState)); }
public IActionResult Post([FromBody] TripViewModel vm) { try { if (!ModelState.IsValid) { return(HttpBadRequest(vm)); } var newTrip = Mapper.Map <Trip>(vm); newTrip.UserName = User.Identity.Name; _repository.AddTrip(newTrip); if (!_repository.SaveAll()) { return(HttpBadRequest()); } _logger.LogInformation("Saving to database"); return(Created("", Mapper.Map <TripViewModel>(newTrip))); } catch (Exception e) { _logger.LogError("Failed to save new trips", e); return(HttpBadRequest(e)); } }
public async Task <JsonResult> Post(TripViewModel trip, StopViewModel stop) { var aTrip = Mapper.Map <Trip>(trip); var aStop = Mapper.Map <Stop>(stop); var longlat = await cs.Lookup(aStop.Name); if (longlat.Success) { aStop.Longitude = longlat.Longitude; aStop.Latitude = longlat.Latitude; } aTrip.Stops.Add(aStop); if (ModelState.IsValid) { db.Trips.Update(aTrip); db.SaveChanges(); } var result = Mapper.Map <TripViewModel>(aTrip); return(Json(result)); }
public async Task <IActionResult> Post([FromBody] TripViewModel theTrip) { if (ModelState.IsValid) { //Save to Database var newTrip = Mapper.Map <Trip>(theTrip); newTrip.UserName = User.Identity.Name; _repository.AddTrip(newTrip); if (await _repository.SaveChangesAsync()) { return(Created($"api/trips/{theTrip.Name}", Mapper.Map <TripViewModel>(newTrip))); } //else //{ // return BadRequest("Save changes Failed in database...."); //} } return(BadRequest("failed to save the trip")); }
public ActionResult InvoicePrint(string voucherNo) { int y = 225; Trip newTrip = _tripService.GetTripDetailsToVoucher(voucherNo); TripViewModel models = new TripViewModel(); if (newTrip != null) { models = AutoMapper.Mapper.Map <TripViewModel>(newTrip); } PrintDocument pd = new PrintDocument(); PaperSize paperSize = new PaperSize(); pd.PrintPage += (sender, args) => { args.Graphics.DrawString(models.VoucherNumber, new System.Drawing.Font("ronnia", 9), Brushes.Black, 600, 28); args.Graphics.DrawString(models.VehicleList.VehicleNumber, new System.Drawing.Font("ronnia", 9), Brushes.Black, 600, 80); args.Graphics.DrawString(models.DriverList.FirstName + " " + models.DriverList.LastName, new System.Drawing.Font("ronnia", 9), Brushes.Black, 600, 103); args.Graphics.DrawString(models.GuestName, new System.Drawing.Font("ronnia", 9), Brushes.Black, 150, 145); args.Graphics.DrawString(models.DispatchedHotel, new System.Drawing.Font("ronnia", 9), Brushes.Black, 150, 176); args.Graphics.DrawString(models.RoomNumber, new System.Drawing.Font("ronnia", 9), Brushes.Black, 150, 203); foreach (var item in models.PackagesList) { args.Graphics.DrawString(item.PreDefineTripName, new System.Drawing.Font("ronnia", 9), Brushes.Black, 150, y); y = y + 15; } args.Graphics.DrawString(models.VehicleList.CurrentMeterReading.ToString(), new System.Drawing.Font("ronnia", 9), Brushes.Black, 500, 177); args.Graphics.DrawString(models.TimeOut.ToString("h:mm tt"), new System.Drawing.Font("ronnia", 9), Brushes.Black, 660, 177); }; pd.Print(); pd.Dispose(); return(RedirectToAction("Index")); }
private TripViewModel MapResultToTripViewModel(dynamic result) { var tripViewModel = new TripViewModel { TripId = result[0].Id, BusId = result[0].BusId, DriverId = result[0].DriverId, ConductorId = result[0].ConductorId, TotalRevenue = result[0].TotalRevenue, TotalTrips = result[0].TotalTrips, TripDate = result[0].TripDate, TripLegs = new List <TripLegViewModel>() }; foreach (var resultRow in result) { var tripLeg = new TripLegViewModel { Route = resultRow.Route, Revenue = resultRow.Revenue }; tripViewModel.TripLegs.Add(tripLeg); } return(tripViewModel); }
public ViewResult Add(string id) { TripViewModel vm = new TripViewModel(); switch (id?.ToLower()) { case "page2": vm.PageNumber = 2; int destinationId = (int)TempData.Peek(nameof(Trip.DestinationId)); vm.DestinationName = data.Destinations.Get(destinationId).Name; vm.Activities = data.Activities.List(new QueryOptions <Activity> { OrderBy = a => a.Name }); return(View("Add2", vm)); case "page1": default: vm.PageNumber = 1; vm.Destinations = data.Destinations.List(new QueryOptions <Destination> { OrderBy = d => d.Name }); vm.Accomodations = data.Accomodations.List(new QueryOptions <Accomodation> { OrderBy = a => a.Name }); return(View("Add1", vm)); } }
public ActionResult TripPlanning() { var model = new TripPlanningViewModel(); if (Request.IsAuthenticated) { // find all trips for the user List <BlViewTrip> _allTrips = null; var blError = TripManager.GetAllTripsForUser(User.Identity.GetUserId(), out _allTrips); model.AllTrips = _allTrips; // find any active trip - to move to a business layer method var _activeTrip = _allTrips.FirstOrDefault(p => (p.DlTripView.Status.Trim() == TripStatus.booked.ToString())); // if there IS an active trip - redirect to view if (_activeTrip != null) { var _tripViewModel = new TripViewModel() { ActiveTrip = _activeTrip }; return(View("Trip", _tripViewModel)); } // else show all the planned trips var _plannedTrips = _allTrips.Where(p => (p.DlTripView.Status.Trim() == TripStatus.planned.ToString() || p.DlTripView.Status.Trim() == TripStatus.consulting.ToString())).ToList(); model.PlannedTrips = _plannedTrips; List <Destination> _destinations = null; blError = DestinationManager.GetTopDestinations("", 8, out _destinations); model.SuggestedDestinations = _destinations; } return(View(model)); }
public void EditTripViewModel() { var trip = new Trip { ChangeSetN = 1, DisplayName = "Trip to Paris", RowId = Guid.NewGuid(), TripId = 1, Expenses = new List<Expense>() }; var oldRowId = trip.RowId; var tripViewModel = new TripViewModel { Model = trip }; tripViewModel.LoadFromModel(); Assert.AreEqual(trip.DisplayName, tripViewModel.DisplayName); Assert.AreEqual(trip.Expenses.Count, tripViewModel.Expenses.Count); tripViewModel.DisplayName = "Trip to Paris/Rome"; tripViewModel.SaveToModel(); Assert.AreNotEqual(oldRowId, trip.RowId); Assert.AreEqual(trip.DisplayName, tripViewModel.DisplayName); }
public async Task <IActionResult> UpdateTrip([FromBody] TripViewModel trip) { try { if (!ModelState.IsValid || trip == null) { return(BadRequest()); } var tripInDb = await _tripService.GetTripById(trip.Id); tripInDb.Departure = trip.Departure; tripInDb.Destination = trip.Destination; tripInDb.DepartureTime = trip.DepartureTime; tripInDb.ArrivalTime = trip.ArrivalTime; tripInDb.Cost = trip.Cost; tripInDb.Miles = trip.Miles; await _tripService.UpdateTrip(tripInDb); return(Ok()); } catch (WebException) { return(BadRequest()); } }
/// <summary> /// Metoda obsługująca pobieranie z bazy danych wszystkich wycieczkek. /// </summary> /// <returns>Lista wycieczek reprezentowanych przez klasę TripViewModel</returns> public List <TripViewModel> GetAll() { var trips = dbContext.Trip .Where(x => x.Status == 1) .ToList(); if (trips == null) { return(null); } List <TripViewModel> tripViewModels = new List <TripViewModel>(); foreach (var x in trips) { var tripViewModel = new TripViewModel { Id = x.Id, Title = x.Title, StartDate = x.StartDate.ToString("dd.MM.yyyy"), EndDate = x.EndDate.ToString("dd.MM.yyyy"), Score = x.Score, Length = x.Length, ElevationGain = x.ElevationGain, }; tripViewModels.Add(tripViewModel); } return(tripViewModels); }
public JsonResult Post([FromBody] TripViewModel vm) { try { if (ModelState.IsValid) { var newTrip = Mapper.Map <Trip>(vm); newTrip.UserName = User.Identity.Name; // Save to the Database _logger.LogInformation("Attempting to save a new trip"); _repository.AddTrip(newTrip); if (_repository.SaveAll()) { Response.StatusCode = (int)HttpStatusCode.Created; return(Json(Mapper.Map <TripViewModel>(newTrip))); } } } catch (Exception ex) { _logger.LogError("Failed to save new trip", ex); Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Message = ex.Message })); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Message = "Failed", ModelState = ModelState })); }
public ActionResult AddCircuitToTrip(int tripId, int templateId = 0) { BlViewTrip trip = null; var _blError = TripManager.GetTripById(tripId, out trip); if (_blError.ErrorCode != 0) { throw new ApplicationException(_blError.ErrorMessage); } var model = new TripViewModel(); model.ActiveTrip = trip; BlTripTemplate template = null; _blError = TripManager.GetTripTemplatesById(templateId, out template); if (_blError.ErrorCode != 0) { throw new ApplicationException(_blError.ErrorMessage); } model.CreateTripTemplate = template; return(View(model)); }
public IActionResult DeletePost(TripViewModel vm, string tripId) { if (!_credentialHoldingService.IsAdmin) { return(RedirectToRoute(new { controller = "Home", action = "Index" })); } if (vm.Delete_Id == 0) { return(RedirectToAction("Index")); } IPost post; if (_context.PostRepository.GetByIdIfExists(vm.Delete_Id, out post)) { System.IO.File.Delete($"{ _env.WebRootPath}/images/{post.PhotoFileName}"); _context.PostRepository.RemovePost(post); _context.SaveChanges(); _context.TripRepository.ResetTimeOnTrip(int.Parse(tripId)); } return(RedirectToAction("ViewTrip", "Trip", new RouteValueDictionary() { { "id", tripId } })); }
public ActionResult CreateTripFromTemplate(int templateId) { // get the trip template BlTripTemplate _template = null; var _blerror = TripManager.GetTripTemplatesById(templateId, out _template); // assign the template to the view model var _model = new TripViewModel(); _model.CreateTripTemplate = _template; var startLocationOptions = _template.DlTemplate.StartLocation.Split('/').ToList(); var _tripStartLocationOptions = new List <SelectListItem>(); foreach (var startLocation in startLocationOptions) { _tripStartLocationOptions.Add(new SelectListItem() { Text = startLocation, Value = startLocation }); } _model.CreateTripStartLocationOptions = _tripStartLocationOptions; _model.CreateTripViewModel = new CreateTripViewModel() { DestinationId = _template.DlTemplate.DestinationId, TemplateId = _template.DlTemplate.Id, StartDate = DateTime.Now }; return(View("Trip", _model)); }
// GET: Trips/Edit/5 public ActionResult Edit(int id) { try { TripViewModel models = new TripViewModel(); DateTime now = CustomDataHelper.CurrentDateTimeSL.GetCurrentDate(); Trip trip = _tripService.GetAllTripDetailsById(id); if (trip != null) { models = AutoMapper.Mapper.Map <TripViewModel>(trip); } models.TimeIn = CustomDataHelper.CurrentDateTimeSL.GetCurrentDate(); TimeSpan span = (now - models.TimeOut); String.Format("{0} days, {1} hours, {2} minutes", span.Days, span.Hours, span.Minutes); models.TripDuration = span.Days.ToString() + " d " + span.Hours.ToString() + " h " + span.Minutes.ToString() + " m "; //models.Trips = GetPreDefined(); models.Passenger = GetGuestType(); models.PaymentTypeList = CustomDataHelper.DataHelper.GetPaymentTypes(); models.PaymentCategoryList = CustomDataHelper.DataHelper.GetPaymentCategories(); models.VehicleRates = AutoMapper.Mapper.Map <IEnumerable <VehicleRateDto> >(_vehicleRateService.GetAllVehicleRates()); return(View(models)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var trip = await _context.Trips .Include(p => p.Traveler) .Include(p => p.Viatics) .FirstOrDefaultAsync(p => p.Id == id.Value); if (trip == null) { return(NotFound()); } var model = new TripViewModel { Id = trip.Id, City = trip.City, Budget = trip.Budget, Date = trip.Date, EndDate = trip.EndDate, Viatics = trip.Viatics, TravelerId = trip.Traveler.Id, }; return(View(model)); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (TripViewModel.Trips.Count < 1) { TripViewModel.LoadTrips(); } }
public async Task <ActionResult> CreateTrip(TripViewModel model) { // create a new Trip object from the form and save it Trip trip = new Trip() { AspNetUserId = User.Identity.GetUserId(), DestinationId = model.CreateTripViewModel.DestinationId, NickName = model.CreateTripViewModel.NickName, StartDate = model.CreateTripViewModel.StartDate, StartLocation = model.CreateTripViewModel.StartLocation, Status = TripStatus.planned.ToString(), HomeLocation = model.CreateTripViewModel.HomeLocation, PaxAdults = model.CreateTripViewModel.Adults, PaxMinors = model.CreateTripViewModel.Minors, TripType = model.CreateTripViewModel.TripType, TripCurrency = model.CreateTripViewModel.Currency, }; var _blError = await TripManager.CreateTrip(trip, model.CreateTripViewModel.TemplateId); if (_blError.ErrorCode > 0) { throw new ApplicationException(_blError.ErrorMessage); } return(RedirectToAction("ViewTrip", new { tripId = trip.Id })); }
public static KeyValuePair<Trip, TripViewModel> AccessSourceManyNestedProperties() { var tripId = Guid.NewGuid(); var categoryId = Guid.NewGuid(); var catalogId = Guid.NewGuid(); var tripCatalog = new TripCatalog { Id = catalogId, Name = "Adventure - changed", }; var categoryTrip = new CategoryTrip { Id = categoryId, Name = "Asia - changed", Catalog = tripCatalog }; var trip = new Trip { Id = tripId, Name = "Fascinating family - changed", Category = categoryTrip }; var tripViewModel = new TripViewModel { Id = tripId }; return new KeyValuePair<Trip, TripViewModel>(trip, tripViewModel); }
public void AddTrip(TripViewModel model) { Trip trip = new Trip() { Description = model.Description, StartPoint = model.StartPoint, EndPoint = model.EndPoint, ImagePath = model.ImagePath, Seats = model.Seats }; DateTime date; DateTime.TryParseExact( model.DepartureTime, "dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out date); trip.DepartureTime = date; repo.Add(trip); repo.SaveChanges(); }
public EstimateViewModel Map(TaxiResponse response) { if (response == null) { return(null); } var vm = new EstimateViewModel { Origin = response.Origin, Destination = response.Destination, Trips = new List <TripViewModel>() }; if (response.Details == null) { return(vm); } foreach (var detail in response.Details) { var trip = new TripViewModel { Information = detail.Details, CarClass = detail.CarType.ToString(), TaxiService = detail.TaxiService.ToString() }; vm.Trips.Add(trip); } return(vm); }
public async Task <IActionResult> Edit(int id, TripViewModel vm) { if (id != vm.trip.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vm.trip); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TripExists(vm.trip.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } // Todo: refactor to view model ApplicationUser user = await GetCurrentUserAsync(); vm.Clients = new SelectList(_context.Client.Where(c => c.ApplicationUserId == user.Id), "Id", "FirstName") ; return(View(vm)); }
// GET: Trips/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var currentTrip = await _context.Trip.FindAsync(id); if (currentTrip == null) { return(NotFound()); } ApplicationUser user = await GetCurrentUserAsync(); TripViewModel vm = new TripViewModel() { trip = currentTrip, Clients = new SelectList(_context.Client.Where(c => c.ApplicationUserId == user.Id), "Id", "FirstName") }; return(View(vm)); }
public IActionResult Add(TripViewModel vm) { switch (vm.PageNumber) { case 1: if (!ModelState.IsValid) { vm.Destinations = data.Destinations.List(new QueryOptions <Destination> { OrderBy = d => d.Name }); vm.Accomodations = data.Accomodations.List(new QueryOptions <Accomodation> { OrderBy = a => a.Name }); return(View("Add1", vm)); } TempData[nameof(Trip.DestinationId)] = vm.Trip.DestinationId; TempData[nameof(Trip.StartDate)] = vm.Trip.StartDate; TempData[nameof(Trip.EndDate)] = vm.Trip.EndDate; if (vm.Trip.AccomodationId > 0) { TempData[nameof(Trip.AccomodationId) vm.Trip.AccomodationId];
public void NewTripViewModel() { var vm = new TripViewModel { DisplayName = "Misc stuff" }; // User clicks "Save" vm.SaveToModel(); var model = vm.Model; Assert.AreEqual(vm.DisplayName, model.DisplayName); Assert.AreNotEqual(default(Guid), model.RowId, "The view should create a new row identifier if it changed the model."); }
/// <summary> /// Called when a page becomes the active page in a frame. /// </summary> /// <param name="e">An object that contains the event data.</param> protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); Debug.Assert(this.NavigationContext.QueryString.ContainsKey("id"), "The 'id' parameter is missing from the query string."); var id = int.Parse(this.NavigationContext.QueryString["id"]); Debug.Assert(id > 0, "The id parameter must be greater than zero."); ////ViewModelStore.Instance.GetOrCreate<Trip, TripViewModel>(id); this.ViewModel = new TripViewModel { Model = (Trip)Repository.Instance[id] }; this.ViewModel.LoadFromModel(); // Won't work anywhere else because it'd overwrite the user's changes. this.ViewModel.PropertyChanged += (a, b) => { if (this.ViewModel.Error == null) { Debug.WriteLine("Saving view model and adding it for sync."); this.ViewModel.SaveToModel(); if (SyncHelper.Instance.Add(new SyncHelperItem { Entity = this.ViewModel.Model })) { Debug.WriteLine("Added model for sync."); } else { Debug.WriteLine("Model was already in queue for sync."); } } else { Debug.WriteLine("Not saving view model because it has validation errors."); } }; if (this.NavigationContext.QueryString.ContainsKey("PanoramaItem")) { if (this.NavigationContext.QueryString["PanoramaItem"] == "Settings") { this.Panorama.DefaultItem = this.SettingsPanoramaItem; } } }
public void EditTripViewModelWithNoChanges() { var trip = new Trip { ChangeSetN = 1, DisplayName = "Trip to Paris", RowId = Guid.NewGuid(), TripId = 1, Expenses = new List<Expense>() }; var oldRowId = trip.RowId; var tripViewModel = new TripViewModel { Model = trip }; tripViewModel.LoadFromModel(); Assert.AreEqual(trip.DisplayName, tripViewModel.DisplayName); Assert.AreEqual(trip.Expenses.Count, tripViewModel.Expenses.Count); tripViewModel.SaveToModel(); Assert.AreEqual(oldRowId, trip.RowId, "The row id should not change unless changes were made."); Assert.AreEqual(trip.DisplayName, tripViewModel.DisplayName); }
public Task SaveTrip(TripViewModel tripViewModel) { return SaveTrip(tripViewModel.Trip); }
public static KeyValuePair<Trip, TripViewModel> ExistingDestinationMediumMap() { var tripId = Guid.NewGuid(); var categoryId = Guid.NewGuid(); var catalogId = Guid.NewGuid(); var typeId = Guid.NewGuid(); var tripType = new TripType { Id = typeId, Name = "Easy - changed", }; var tripTypeViewModel = new TripTypeViewModel { Id = typeId, Name = "Easy", }; var tripCatalog = new TripCatalog { Id = catalogId, Name = "Adventure - changed", TripType = tripType }; var tripCatalogViewModel = new TripCatalogViewModel { Id = catalogId, Name = "Adventure", TripType = tripTypeViewModel }; var categoryTrip = new CategoryTrip { Id = categoryId, Name = "Asia - changed", Catalog = tripCatalog }; var categoryTripViewModel = new CategoryTripViewModel { Id = categoryId, Name = "Asia", Catalog = tripCatalogViewModel }; var trip = new Trip { Id = tripId, Name = "Fascinating family - changed", Category = categoryTrip }; var tripViewModel = new TripViewModel { Id = tripId, Name = "Fascinating family", Category = categoryTripViewModel }; return new KeyValuePair<Trip, TripViewModel>(trip, tripViewModel); }
public void OpenDetails(TripViewModel trip) { TripContent.Content = new TripView(this, trip); SetBackgroundToLocation(trip.Trip); }
private async void OnTripAdded(string name, DateTime date, string glyph) { TripViewModel trip = new TripViewModel(new Trip { Name = name, Date = date, Icon = glyph }); CurrentTripList.Add(trip); OpenDetails(trip); await Backend.Azure.SaveTrip(trip); SetBackgroundToLocation(trip.Trip); }
public Task SaveTripWithoutItems(TripViewModel tripViewModel) { return SaveTripWithoutItems(tripViewModel.Trip); }