async void DoCreateAccountCommand() { User user = new User { email = Email, username = Username, password = EncryptionService.encrypt(Password), name = Name, lastname = Lastname, image_url = UserImageUrl, created_at = DateTime.Now, updated_at = DateTime.Now }; try { OperationResult result = await _mLearningService.CreateAccount <User>(user, (usr) => usr.id, _selectedUserType); SessionService.LogIn(result.id, Username); SharedPreferences prefs = Constants.GetSharedPreferences(Constants.PreferencesFileName); prefs.PutString(Constants.UserFirstNameKey, Name); prefs.PutString(Constants.UserLastNameKey, Lastname); prefs.PutString(Constants.UserImageUrlKey, UserImageUrl); prefs.Commit(); ClearProperties(); ShowViewModel <MainViewModel>(); RegistrationOK = true; } catch (WebException e) { ConnectionOK = false; } catch (MobileServiceInvalidOperationException ex) { OperationOK = false; } }
async void DoAddPublisherCommand() { var user = new User { name = FirstName, lastname = LastName, username = Username, password = EncryptionService.encrypt(Password), email = Email }; OperationResult r = await _mLearningService.CreateAccount <User>(user, u => u.id, UserType.Publisher); _mLearningService.CreateObject <Institution_has_User>(new Institution_has_User { institution_id = Institution_id, user_id = r.id, created_at = DateTime.UtcNow, updated_at = DateTime.UtcNow }, ins => ins.id); Close(this); }
async void DoCreateAccountCommand() { User user = new User { email = Email, username = Username, password = EncryptionService.encrypt(Password), name = Name, lastname = Lastname, created_at = DateTime.Now, updated_at = DateTime.Now }; try { OperationResult result = await _mLearningService.CreateAccount <User>(user, (usr) => usr.id, SelectedUserType); SessionService.LogIn(result.id, Username); ClearProperties(); ShowViewModel <MainViewModel>(); } catch (WebException e) { ConnectionOK = false; } catch (MobileServiceInvalidOperationException ex) { OperationOK = false; } }