private async void Page_Loaded(object sender, RoutedEventArgs e) { var ids = new List <int>(); var normalUserLoggedIn = false; try { await AuthenticationViewModel.IsAdminAsync(); await AccommodationViewModel.GetAllAccommodationsAsync(); foreach (var acc in AccommodationViewModel.AllAccommodations) { ids.Add(acc.Id); } } catch (Exception) { normalUserLoggedIn = true; } finally { await FillComboboxWithAccommodationIds(ids, normalUserLoggedIn); } }
public AccommodationViewModel GetAccommodationViewModel(long id) { var accommodation = _accommodationRepository.GetAccommodation(id); var reviews = _reviewRepository.GetAccomodationReviews(id); return(AccommodationViewModel.FromAccommodation(accommodation, reviews.Where(x => x.Approved).ToList())); }
public static AccommodationViewModel ToViewModel(this Accommodation model) { if (model != null) { AccommodationViewModel viewModel = new AccommodationViewModel(); viewModel.Id = model.Id; viewModel.AveragePrice = model.AveragePrice; viewModel.Comments = model.Comments; viewModel.Conveniences = model.Conveniences; viewModel.Images = model.Images; viewModel.LocationId = model.LocationId; viewModel.Name = model.Name; viewModel.Rating = model.Rating; viewModel.Rooms = model.Rooms; viewModel.Services = model.Services; viewModel.Description = model.Description; viewModel.Policies = model.Policies; viewModel.LocationAssessment = model.LocationAssessment; viewModel.SanitaryConditionsAssessment = model.SanitaryConditionsAssessment; viewModel.ServiceAssessment = model.ServiceAssessment; viewModel.RoomQualityAndComfortAssessment = model.RoomQualityAndComfortAssessment; viewModel.CostAssessment = model.CostAssessment; viewModel.ConvenientAssessment = model.ConvenientAssessment; return(viewModel); } return(null); }
public Accommodation() { InitializeComponent(); vm = new AccommodationViewModel(); BindingContext = vm; primary_accommodation_image.Source = ImageSource.FromResource("DestinationLaikipia.Assets.Images.nanyuki_scenary.jpg"); }
public HttpResponseMessage Post(AccommodationViewModel model) { if (ModelState.IsValid) { ClientViewModel client = _clientRepository.Get(model.ClientId); if (client == null) { throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("Client not found") }); } RoomViewModel room = _roomRepository.Get(model.RoomId); if (room == null) { throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("Room not found") }); } else if (!room.Available) { throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.Conflict, Content = new StringContent("Room is not available.") }); } try { client = _repository.AccommodateClient(model); } catch { throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, Content = new StringContent("Something goes wrong.") }); } var response = Request.CreateResponse <ClientViewModel>(HttpStatusCode.Created, client); string uri = Url.Link("DefaultApi", new { id = model.ClientId }); response.Headers.Location = new Uri(uri); return(response); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public async Task <IActionResult> Update([FromBody] AccommodationViewModel viewModel) { var model = Mapper.Map <Accommodation>(viewModel); var updatedModel = await _accommodationService.UpdateAsync(model); var updatedViewModel = Mapper.Map <AccommodationViewModel>(updatedModel); return(Ok(updatedViewModel)); }
public AccommodationWindow(int travelersCount, string guid) { InitializeComponent(); AccommodationViewModel vm = new AccommodationViewModel(travelersCount, guid); this.DataContext = vm; if (vm.CloseAction == null) { vm.CloseAction = new Action(this.Close); } }
public ClientViewModel AccommodateClient(AccommodationViewModel model) { ClientViewModel client = _clientRepository.Get(model.ClientId); client.RoomNumber = model.RoomId; _clientRepository.Update(client); _roomRepository.ChangeStatus(model.RoomId, false); return(client); }
public async Task <StatusCodeResult> Update([FromBody] AccommodationViewModel viewModel) { if (await _service.UpdateAsync(viewModel.ToModel()) == 1) { return(StatusCode((int)HttpStatusCode.OK)); } else { return(StatusCode((int)HttpStatusCode.ExpectationFailed)); } }
private async Task SortAsync(string sortBy, string ascOrDesc, Button hide, Button show) { AccommodationViewModel.SortBy = sortBy; AccommodationViewModel.AscOrDesc = ascOrDesc; await AccommodationViewModel.SortAvailableListAsync(); listView.ItemsSource = AccommodationViewModel.AllAccommodations; hide.Visibility = Visibility.Collapsed; show.Visibility = Visibility.Visible; }
public async Task <IActionResult> Create([FromBody] AccommodationViewModel viewModel) { var model = Mapper.Map <Accommodation>(viewModel); var createdModel = await _accommodationService.AddAsync(model); var createdViewModel = Mapper.Map <AccommodationViewModel>(createdModel); return(CreatedAtRoute( nameof(AccommodationController.GetById), new { id = createdViewModel.Id }, createdViewModel)); }
private async void Button_Click_Expand(object sender, RoutedEventArgs e) { try { await AccommodationViewModel.ExpandScheduleOfAccommodationAsync(); await new MessageDialog("Expansion of schedule ok").ShowAsync(); } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } }
private async void Button_Click_Update(object sender, RoutedEventArgs e) { try { await AccommodationViewModel.UpdateAccommodationAsync(); await new MessageDialog("Update ok").ShowAsync(); } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } }
private async Task DeleteAcc() { try { await AccommodationViewModel.DeleteAccommodationAsync(); await new MessageDialog("Deletion ok!").ShowAsync(); Frame.Navigate(typeof(AllAccommodationsPage)); } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } }
private async void Button_Click_Create_Accommadtion(object sender, RoutedEventArgs e) { try { await AccommodationViewModel.CreateAccommodationAsync(); await new MessageDialog("Creation ok!").ShowAsync(); Frame.Navigate(typeof(AllAccommodationsPage)); } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } }
private async Task FillListViewAsync() { try { await AccommodationViewModel.GetAvailableAsync(); RatingAsc.Visibility = Visibility.Visible; PriceAsc.Visibility = Visibility.Visible; SizeAsc.Visibility = Visibility.Visible; DistanceAsc.Visibility = Visibility.Visible; } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } }
public async Task <IActionResult> Create(int?id, AccommodationViewModel accommodationViewModel) { if (ModelState.IsValid) { var details = mapper.MapFrom(accommodationViewModel); try { await service.CreateAsync(accommodationViewModel.FacilityId, details); return(RedirectToAction("details", "facility", new { id = accommodationViewModel.FacilityId })); } catch (FacilityNotFoundException) { return(View("NotFound")); } } ViewBag.FacilityId = accommodationViewModel.FacilityId; return(View(accommodationViewModel)); }
private async void ComboBoxAccommodations_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { AccommodationViewModel.Accommodation.Id = int.Parse(ComboBoxAccommodations.SelectedValue.ToString()); await AccommodationViewModel.GetAccommodationAsync(); ImageViewModel.Image.Accommodation = AccommodationViewModel.Accommodation; await ImageViewModel.GetAllPicturesAsync(); } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } ShowButtons(); await ImageViewModel.GetAllPicturesAsync(); }
private async Task FillComboboxWithAccommodationIds(List <int> ids, bool normalUserLoggedIn) { if (normalUserLoggedIn) { AccommodationViewModel.UserId = AuthenticationViewModel.IdOfLoggedInUser; try { await AccommodationViewModel.GetAllAccommodationsOfAUserAsync(); foreach (var acc in AccommodationViewModel.AllAccommodations) { ids.Add(acc.Id); } } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } } ComboBoxAccommodations.ItemsSource = ids; }
public AccommodationDeletedMessage(AccommodationViewModel sender) : base(sender) { Accommodation = sender; }
public AccommodationDetails MapFrom(AccommodationViewModel viewModel) { return(Mapper.Map <AccommodationDetails>(viewModel)); }