예제 #1
0
        private async void returner_ClickAsync(object sender, EventArgs e)
        {
            string           search   = this.Title.Text.ToString();
            FirebaseResponse response = await client.GetTaskAsync("Book/" + search);

            ApplicationEngine.Book.Book result = response.ResultAs <ApplicationEngine.Book.Book>();

            string           searchCH   = this.UserId.Text.ToString();
            FirebaseResponse responseCH = await client.GetTaskAsync("CardHolder/" + searchCH);

            ApplicationEngine.UserTypes.Cardholder resultCH = responseCH.ResultAs <ApplicationEngine.UserTypes.Cardholder>();



            if (result.RemoveHolder(Convert.ToInt32(this.UserId.Text.ToString())) && resultCH.ReturnBook(result))
            {
                result.Available += 1;
                SetResponse res = await client.SetTaskAsync("Book/" + result.Title, result);

                Book        results = res.ResultAs <Book>();
                SetResponse resCH   = await client.SetTaskAsync("CardHolder/" + resultCH.ID, resultCH);

                ApplicationEngine.UserTypes.Cardholder resulCH = resCH.ResultAs <ApplicationEngine.UserTypes.Cardholder>();
            }
            else
            {
                MessageBox.Show("User should not have this book");
            }
        }
        private async void searchClick_ClickAsync(object sender, EventArgs e)
        {
            string           search   = this.search.Text.ToString();
            FirebaseResponse response = await client.GetTaskAsync("Book/" + search);

            ApplicationEngine.Book.Book result = response.ResultAs <ApplicationEngine.Book.Book>();

            this.Title.Text     = result.Title;
            this.Date.Text      = result.Date;
            this.Author.Text    = result.Author;
            this.ISBN.Text      = result.ISBN.ToString();
            this.Genre.Text     = result.Genre.ToString();
            this.Available.Text = result.Available.ToString();

            string x = "";

            foreach (int i in result.Holder)
            {
                x = x + i.ToString() + "\r\n";
            }
            this.CardHolder.Text = x;
        }
예제 #3
0
        private async void Submit_ClickAsync(object sender, EventArgs e)
        {
            string           search   = this.Title.Text.ToString();
            FirebaseResponse response = await client.GetTaskAsync("Book/" + search);

            ApplicationEngine.Book.Book result = response.ResultAs <ApplicationEngine.Book.Book>();


            string           searchCH   = this.UserId.Text.ToString();
            FirebaseResponse responseCH = await client.GetTaskAsync("CardHolder/" + searchCH);

            ApplicationEngine.UserTypes.Cardholder resultCH = responseCH.ResultAs <ApplicationEngine.UserTypes.Cardholder>();

            if (result.Available > 0)
            {
                if (result.AddHolder(Convert.ToInt32(this.UserId.Text.ToString())) && resultCH.AddBook(result))
                {
                    result.Available -= 1;
                    SetResponse res = await client.SetTaskAsync("Book/" + result.Title, result);

                    Book results = res.ResultAs <Book>();


                    SetResponse resCH = await client.SetTaskAsync("CardHolder/" + resultCH.ID, resultCH);

                    ApplicationEngine.UserTypes.Cardholder resultsCH = resCH.ResultAs <ApplicationEngine.UserTypes.Cardholder>();
                }
                else
                {
                    MessageBox.Show("User already has book");
                }
            }
            else
            {
                MessageBox.Show("None Available");
            }
        }