private async void completeForm() { var model = new Book { Photo = "https://d1w7fb2mkkr3kw.cloudfront.net/assets/images/book/lrg/9781/1188/9781118881170.jpg", Edition = editionInput.Text, Title = titleInput.Text, Author = authorInput.Text, Posted = DateTime.Now, Faculty = facultySelection.SelectedItem.ToString(), CourseCode = courseCodeInput.Text, Price = float.Parse(priceInput.Text), Condition = conditionSelection.SelectedItem.ToString(), Description = descInput.Text.Trim(), Campus = campusSelection.SelectedItem.ToString() }; model.BooksImgs = JsonConvert.SerializeObject(imagePaths); //---------------------------------------------------------------------------// #region //Book book = new Book(); //book.Title = titleInput.Text.Trim(); //titleInput.Text = null; //book.Author = authorInput.Text.Trim(); //authorInput.Text = null; //book.Edition = editionInput.Text.Trim(); //editionInput.Text = null; //book.CourseCode = courseCodeInput.Text.Trim(); //courseCodeInput.Text = null; //book.Faculty = facultySelection.SelectedItem.ToString(); //facultySelection.SelectedIndex = 0; //book.Condition = conditionSelection.SelectedItem.ToString(); //conditionSelection.SelectedIndex = 0; //book.Description = descInput.Text.Trim(); //descInput.Text = null; //book.Price = float.Parse(priceInput.Text.Trim()); //priceInput.Text = null; //book.Campus = "City"; #endregion UsersDb.AddUser(new User()); BooksDb.AddBook(model); await DisplayAlert("Complate", "Your Book will post on the list soon", "OK"); Application.Current.MainPage = new HomePage(); await Shell.Current.GoToAsync("//main"); }
public void getChildData() { Items.Clear(); var list = BooksDb.GetBooks(1); foreach (var item in list) { Items.Add(item); } Debug.WriteLine(JsonConvert.SerializeObject(Items)); }
private async void Remove_Clicked(object sender, EventArgs e) { var check = await DisplayAlert("Warning", "Are you Sure? ", "Yes", "No"); if (check) { var removeBtn = sender as ImageButton; var book = removeBtn?.BindingContext as Book; BooksDb.RemoveBook(book); vm?.RemoveBook.Execute(book); } }
public void getShortLiistOfCondition(string condition) { ObservableCollection <Book> books = BooksDb.GetBookss(); ObservableCollection <Book> resultBook = new ObservableCollection <Book>(); foreach (Book book in books) { if (book.Condition.Equals(condition)) { resultBook.Add(book); } } getBooks = resultBook; }
private static void Seedooks() { using var db = new BooksDb(); try { if (db.Books.Any() == false) { Console.WriteLine("\nInserting..."); var authors = new List <Author> { new Author { AuthorId = 1, FirstName = "John", LastName = "Lennon" }, new Author { AuthorId = 2, FirstName = "Frank", LastName = "Zappa" } }; var books = new List <Book>() { new Book { BookId = 1, AuthorId = 1, Title = "In His On Right" }, new Book { BookId = 2, AuthorId = 1, Title = "Yer Blues" }, new Book { BookId = 3, AuthorId = 2, Title = "Led World" }, }; db.Authors.AddRange(authors); db.Books.AddRange(books); db.SaveChanges(); } } catch (Exception exception) { Console.WriteLine($"Exception: {exception.Message}"); return; } Console.WriteLine("\nREADING"); foreach (var book in db.Books.Include(x => x.Author).ToList()) { Console.WriteLine(book); } }
public BaseService(BooksDb db) { _db = db; }
public UserService() { _db = new BooksDb(); }
public void getUserBook() { getBooks = BooksDb.GetBookByUser(new User()); }
public TestBooksViewModel(INavigation Navigation) { this.Navigation = Navigation; getBooks = BooksDb.GetBookss(); }