예제 #1
0
        void DoCreateConsumerCommand()
        {
            var user = new User {
                name = FirstName, lastname = LastName, username = Username, password = EncryptionService.encrypt(Password), email = Email
            };

            _mLearningService.CreateAndRegisterConsumer(user, InstitutionID);

            ConsumersList.Add(new consumer_by_institution {
                username = user.username
            });

            ClearProperties();
        }
        async void DoRegisterCommand1()
        {
            try
            {
                MLearningDB.User newuser = new MLearningDB.User {
                    email = Email, username = RegUsername, password = EncryptionService.encrypt(RegPassword), name = Name, lastname = ":)", image_url = "http://www.clinicatorielli.com/img/icons/no-user.png", created_at = DateTime.Now, updated_at = DateTime.Now
                };


                int idInstitution = 1;
                newuser.password = EncryptionService.encrypt(newuser.password);
                bool exists = await _mLearningService.CheckIfExistsNoLocale <MLearningDB.User>
                                  (usr => usr.username == newuser.username, (it) => it.updated_at, it => it.id);

                if (exists)
                {
                    return;
                }

                OperationResult op = await _mLearningService.CreateAndRegisterConsumer(newuser, idInstitution);

                MLearningDB.User user = new MLearningDB.User {
                    username = newuser.username, password = newuser.password
                };

                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>();
            }
            catch (MobileServiceInvalidOperationException e) {
                ConnectionOK = false;
            }
            catch (WebException e)
            {
                ConnectionOK = false;
            }
        }