private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (FieldValidationExtensions.GetIsValid(AddressbookUserName) && FieldValidationExtensions.GetIsValid(AddressbookEmail))
            {
                var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
                using (var db = new SQLite.SQLiteConnection(dbPath))
                {
                    db.CreateTable <AddressBookEntree>();

                    User addressbookuser = new User();
                    addressbookuser.UserName     = AddressbookUserName.Text;
                    addressbookuser.EmailAddress = AddressbookEmail.Text;

                    db.RunInTransaction(() =>
                    {
                        db.Insert(addressbookuser);

                        db.Insert(new AddressBookEntree()
                        {
                            OwnerUserID = App.loggedInUser.Id, EntreeUserID = addressbookuser.Id
                        });
                    });
                }
            }

            this.Frame.Navigate(typeof(Dashboard));
        }
Example #2
0
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            if (FieldValidationExtensions.GetIsValid(RegisterUserName) && FieldValidationExtensions.GetIsValid(RegisterPassword) && FieldValidationExtensions.GetIsValid(RegisterEmail))
            {
                var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
                using (var db = new SQLite.SQLiteConnection(dbPath))
                {
                    db.CreateTable <User>();

                    db.RunInTransaction(() =>
                    {
                        db.Insert(new User()
                        {
                            UserName = RegisterUserName.Text, PassWord = RegisterPassword.Password, EmailAddress = RegisterEmail.Text
                        });
                    });
                }

                this.Frame.Navigate(typeof(MainPage));
            }
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (FieldValidationExtensions.GetIsValid(RequestTitle) && FieldValidationExtensions.GetIsValid(RequestLocation) && FieldValidationExtensions.GetIsValid(RequestDescription))
            {
                var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
                using (var db = new SQLite.SQLiteConnection(dbPath))
                {
                    db.CreateTable <Appointment>();
                    db.CreateTable <AppointmentInvitee>();

                    Appointment appointment = new Appointment();
                    appointment.Title       = RequestTitle.Text;
                    appointment.Location    = RequestLocation.Text;
                    appointment.Description = RequestDescription.Text;
                    appointment.Date        = RequestDate.SelectedDate;
                    appointment.OwnerUserID = App.loggedInUser.Id;

                    db.RunInTransaction(() =>
                    {
                        db.Insert(appointment);

                        foreach (UserSelected item in mUsersSelected)
                        {
                            if (item.IsSelected)
                            {
                                db.Insert(new AppointmentInvitee()
                                {
                                    OwnerUserID = App.loggedInUser.Id, InviteeAppointmentID = appointment.Id, InviteeUserID = item.Id
                                });
                            }
                        }
                    });
                }

                this.Frame.Navigate(typeof(Dashboard));
            }
        }