Ejemplo n.º 1
0
 public DashboardModel()
 {
     User          = new UserModel();
     Book          = new BookModel();
     GoogleAPIBook = new googleAPIBook();
     UserBook      = new UserBookModel();
 }
Ejemplo n.º 2
0
 public DashboardModel(IHttpContextAccessor httpContextAccessor)
 {
     HttpContextAccessor = httpContextAccessor;
     User          = new UserModel();
     Book          = new BookModel();
     GoogleAPIBook = new googleAPIBook();
     UserBook      = new UserBookModel();
 }
Ejemplo n.º 3
0
 public DashboardModel(IHttpContextAccessor httpContextAccessor, ITempDataDictionaryFactory tempData)
 {
     HttpContextAccessor = httpContextAccessor;
     MyTempData          = tempData;
     User          = new UserModel();
     Book          = new BookModel();
     GoogleAPIBook = new googleAPIBook();
     UserBook      = new UserBookModel();
 }
Ejemplo n.º 4
0
        public bool insertUserBook(UserBookModel userBook, int idBook)
        {
            if (userBook.Review != null)
            {
                userBook.Review = MySqlHelper.EscapeString(userBook.Review);
            }
            string sql = $"insert into UserBook (idUser, idBook, idReading, DateRead, Rating, Review, CanPublishIt)values " +
                         $"('{userBook.IdUser}', '{idBook}', {userBook.IsReading}, '{userBook.DateRead.ToString("yyyy-MM-dd")}', '{userBook.Rating}', '{userBook.Review}', {userBook.CanPublishIt})";
            ConnectionDB connection = new ConnectionDB();

            try
            {
                connection.executeComandSQL(sql);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        public bool updateUserBook(UserBookModel userBook, int bookId)
        {
            if (userBook.Review != null)
            {
                userBook.Review = MySqlHelper.EscapeString(userBook.Review);
            }
            string sql = "UPDATE userbook SET " +
                         $"idReading = {userBook.IsReading}, DateRead = '{userBook.DateRead.ToString("yyyy-MM-dd")}', " +
                         $"Rating = {userBook.Rating}, Review = '{userBook.Review}', CanPublishIt = {userBook.CanPublishIt} " +
                         $"where idUser = {userBook.IdUser} and idBook = {bookId}";

            try
            {
                ConnectionDB connection = new ConnectionDB();
                connection.executeComandSQL(sql);
                return(true);
            }
            catch
            {
                return(false);
            }
        }