public MyConversationsRouteViewModel(RouteItemViewModel routeView) { this.apiService = new ApiService(); this.route = routeView; this.LoadConversations(); }
private async void GotoConversation() { var route = new RouteItemViewModel() { RouteId = this.RouteId, UserId = this.UserId, }; MainViewModel.GetInstance().MyConversations = new MyConversationsViewModel(route); await App.Navigator.PushAsync(new MyConversationPage()); }
public EditRouteViewModel(RouteItemViewModel routeItemViewModel) { this.apiService = new ApiService(); this.RouteItem = routeItemViewModel; this.Date = new DateTime(this.RouteItem.Date.Year, this.RouteItem.Date.Month, this.RouteItem.Date.Day); this.Time = new TimeSpan(this.RouteItem.Date.Hour, this.RouteItem.Date.Minute, this.RouteItem.Date.Second); this.MinimumDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day); this.NumOfSeats = Int32.Parse(routeItemViewModel.NumSeats); this.Description = routeItemViewModel.Description; this.ImageSource = (!string.IsNullOrEmpty(RouteItem.ImagePath)) ? RouteItem.ImageFullPath : "no_image"; this.LoadCities(); }
public DetailRouteViewModel(RouteItemViewModel routeView) { this.apiService = new ApiService(); this.RouteView = routeView; var loggerUser = JsonConvert.DeserializeObject <CustomUserASP>(Settings.UserASP); this.IsOwner = false; this.IsVisible = true; this.ImageSource = (!string.IsNullOrEmpty(RouteView.ImagePath)) ? RouteView.ImageFullPath : "no_image"; if (routeView.UserId == loggerUser.Id) { this.IsOwner = true; this.IsVisible = false; } }
public MyConversationsViewModel(RouteItemViewModel routeView) { instance = this; this.apiService = new ApiService(); this.route = routeView; #region RealTime Section ChatMessage = new MessageItemViewModel(); ChatMessageRT = new ChatMessage(); SendMessageCommand = new Command(async() => await SendMessage()); ConnectCommand = new Command(async() => await Connect()); DisconnectCommand = new Command(async() => await Disconnect()); random = new Random(); #endregion LoadMessages(); #if DEBUG var ip = "localhost"; if (Device.RuntimePlatform == Device.Android) { ip = "10.0.2.2"; } hubConnection = new HubConnectionBuilder() .WithUrl($"http://{ip}:5000/chatHub") .Build(); #else hubConnection = new HubConnectionBuilder() .WithUrl("http://movilidaducarealtime.azurewebsites.net/chatHub") .Build(); #endif hubConnection.Closed += async(error) => { IsConnected = false; SendLocalMessage("Connection Closed..."); await Task.Delay(random.Next(0, 5) * 1000); await Connect(); }; hubConnection.On <string, string>("ReceiveMessage", (user, message) => { var finalMessage = new MessageItemViewModel { Sender = user, Message = message, Date = DateTime.Now, ConectionId = this.Conversation.ConnectionId }; if (user != MainViewModel.GetInstance().UserASP.Email) { Messages.Add(finalMessage); } var finMessage = $"{user} says {message}"; SendLocalMessage(finMessage); }); hubConnection.On <string>("EnteredOrLeft", (message) => { SendLocalMessage(message); }); }