public AddUpdateViewModel(IUserAPI api, UserModel userModel = null) { userApi = api; model = userModel; IsSaveSuccessful = false; operationType = userModel == null ? Operations.CreateNewUser : Operations.UpdateUser; WindowCaption = userModel == null ? "Add New User" : "Update User"; SaveButtonCaption = userModel == null ? "Add" : "Update"; SaveCommand = new SimpleCommand(OnSave, CanSave); if (userModel != null) { SetUserModel(userModel); } }
public MainWindowViewModel(IUserAPI api) { SetDefaults(); //initillize the user api userApi = api; //fetch the users data on load OnGetUsers("First"); //Instantiate all the commands SearchUserCommand = new SimpleCommand(OnSearchUser, CanSearchUser); GetUsersCommand = new SimpleCommand(OnGetUsers, CanGetUsers); FirstPageCommand = new SimpleCommand(OnGetUsers, CanGetUsers); PreviousPageCommand = new SimpleCommand(OnGetUsers, CanGetUsers); NextPageCommand = new SimpleCommand(OnGetUsers, CanGetUsers); LastPageCommand = new SimpleCommand(OnGetUsers, CanGetUsers); AddUserCommand = new SimpleCommand(OnAddUpdateUser, CanAddUpdateUser); UpdateUserCommand = new SimpleCommand(OnAddUpdateUser, CanAddUpdateUser); DeleteUserCommand = new SimpleCommand(OnDeleteUser, CanDeleteUser); }
public LogInPageViewModel(IAuthenticationHelper _helper, INavigationService _service, IUserAPI _userAPI) { helper = _helper; service = _service; userAPI = _userAPI; //gets called when app starts InitCommand = new RelayCommand(async o => { account = await helper.GetAccountAsync(); if (account != null) { //check api if user exists var user = await userAPI.GetMyself(); //navigate to main page if (user != null) { CommonAttributes.account = account; service.Navigate(typeof(MainPage), null); } else { service.Navigate(typeof(RegisterPage), account); } } }); //gets called when log in button is pressed LogInCommand = new RelayCommand(async o => { account = await helper.GetAccountAsync(); //navigate to main page if (account == null) { //pop up sign in page account = await helper.SignInAsync(); //if sign in is successfull if (account != null) { CommonAttributes.account = account; //check api if user exists var user = await userAPI.GetMyself(); if (user == null) { service.Navigate(typeof(RegisterPage), account); } else { service.Navigate(typeof(MainPage), null); } } } else { CommonAttributes.account = account; //check api if user exists var user = await userAPI.GetMyself(); if (user == null) { service.Navigate(typeof(RegisterPage), account); } else { service.Navigate(typeof(MainPage), null); } } }); }
public UserService(string url) { Url = url; userProxy = XmlRpcProxyGen.Create<IUserAPI>(); userProxy.Url = Url; userProxy.Proxy = new WebProxy("http://144.16.192.245:8080"); LoggedIn = false; }
public UserService(Repository source) { Source = source; userProxy = XmlRpcProxyGen.Create<IUserAPI>(); userProxy.Url = source.Url; Console.WriteLine ("The url is " + userProxy.Url); if(source.Proxy != "") { Console.WriteLine ("The proxy is :" + source.Proxy); userProxy.Proxy = new WebProxy(source.Proxy); } LoggedIn = false; }