async void ExecuteRegistrationCommand() { if (RegistrationPassword != ConfirmPassword) { MessageBox.Show("Password and confirmation password do not match."); return; } UserModel userModel = new UserModel { Login = RegistrationLogin, Password = RegistrationPassword, UserName = Username }; try { string response = await WebApiConsumer.ConsumePostAsJsonAsync("users", userModel); if (!string.IsNullOrEmpty(response)) { UserModel user = JsonConvert.DeserializeObject <UserModel>(response); CurrentUserHelper.Instance.SetUserDetails(user); ClearRegistraton(); var currentRegion = regionManager.Regions["LoginViewRegion"]; if (currentRegion != null) { currentRegion.RequestNavigate(new Uri("Dashboard", UriKind.Relative)); } } } catch (Exception) { MessageBox.Show("There is a problem on Registration. Please try again"); } }
//Called when the SaveGuest command is executed, private void ExecuteSaveGuestCommand() { try { List <GuestModel> guestModels = new List <GuestModel>(); foreach (var item in guestCollection) { guestModels.Add(new GuestModel { Age = item.Age, CheckInDate = item.CheckInDate, CheckOutDate = item.CheckOutDate, GuestName = item.GuestName, RoomId = selectedRoom.RoomId, Sex = item.Sex }); } var response = WebApiConsumer.ConsumePostAsJsonAsync("guest", guestModels); MessageBox.Show("Record saved successfully"); } catch (Exception) { MessageBox.Show("Error occurs while saving. Retry Again!"); } }
async void ExecuteLoginCommand() { UserModel userModel = new UserModel { Login = LoginUserName, Password = LoginPassword }; try { string response = await WebApiConsumer.ConsumePostAsJsonAsync("login", userModel); if (!string.IsNullOrEmpty(response)) { UserModel user = JsonConvert.DeserializeObject <UserModel>(response); CurrentUserHelper.Instance.SetUserDetails(user); var currentRegion = regionManager.Regions["LoginViewRegion"]; if (currentRegion != null) { currentRegion.RequestNavigate(new Uri("Dashboard", UriKind.Relative)); } ClearLogin(); } } catch (Exception) { MessageBox.Show("There is a problem while login. Please try again"); } }
async void ExecuteSaveCommand() { RoomModel roomModel = new RoomModel { Address = this.Address, Capacity = this.Capacity, Location = this.Location, RoomName = this.RoomName }; try { string response = await WebApiConsumer.ConsumePostAsJsonAsync("room", roomModel); } catch (Exception) { MessageBox.Show("Error occurs while saving. Retry Again!"); } }