public CoworkingDetailPage() { InitializeComponent(); localStorage = new LocalStorage(); //TODO: Refactor var cw = GlobalObjectsHelper.SelectedCoworking; var opt = GlobalObjectsHelper.CwSearchOptions; if (opt.BeginDate != null && opt.EndDate != null && opt.BeginWork != null && opt.BeginWork != null) { var freeSeats = new CoworkingsHelper().GetAvailableSeats(cw.Id, СorrectDate(opt.BeginDate.Value, opt.BeginWork.Value), СorrectDate(opt.EndDate.Value, opt.EndWork.Value)); var seatsCount = 0; if (freeSeats.Status == System.Net.HttpStatusCode.OK) { seatsCount = freeSeats.SeatsNum.Value; } GlobalObjectsHelper.SelectedCoworking.UpdateSeatsAvailable(seatsCount); } int count = cw.WorkingDays.Count; Hours1.ItemsSource = cw.WorkingDays.GetRange(0, Math.Min(WDAYS_COUNT, count)); if (cw.WorkingDays.Count > WDAYS_COUNT) { Hours2.ItemsSource = cw.WorkingDays.GetRange(WDAYS_COUNT, count - WDAYS_COUNT); } foreach (var amenty in cw.Amenties) { var imgSource = IconGetter.GetAmentyIcon(amenty.RawName); if (imgSource != null) { var stack = new StackLayout(); var label = new Label { Text = amenty.Name, TextColor = Color.Black }; var img = new AmentyImage { Source = ImageSource.FromFile(imgSource), WidthRequest = 50, HeightRequest = 50, Value = amenty.Description }; img.Clicked += OnAmenty; stack.Children.Add(img); stack.Children.Add(label); Amenties.Children.Add(stack); } } Task.Run(() => { LoadImages(cw); }); BindingContext = cw; }
public LocalStorage() { dbHelper = DBHelper.Instance; imagesHelper = new ImagesHelper(); coworkingsHelper = new CoworkingsHelper(); }