Beispiel #1
0
        public int post(PublicherModel publichermoudel)
        {
            if ((context.Publishers.FirstOrDefault(ww => ww.Name == publichermoudel.Name) == null))

            {
                publisher publisher = new publisher();
                publisher.Name = publichermoudel.Name;
                context.Publishers.Add(publisher);
                context.SaveChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
Beispiel #2
0
        public int addcategory(PublicherModel cat)
        {
            var checkcategory = context.Categories.FirstOrDefault(ww => ww.CategoryName == cat.Name);

            if (checkcategory == null)
            {
                Category c = new Category();
                c.CategoryName = cat.Name;
                context.Categories.Add(c);
                context.SaveChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
Beispiel #3
0
        public int addpublisher(PublicherModel publish)
        {
            var checkpublisher = context.Publishers.FirstOrDefault(ww => ww.Name == publish.Name);

            if (checkpublisher == null)
            {
                publisher p = new publisher();
                p.Name = publish.Name;

                context.Publishers.Add(p);
                context.SaveChanges();
                return(1);
            }
            else
            {
                return(0);
            }
        }
Beispiel #4
0
        public getbookbysearch searchBooks(string book)
        {
            PublicherModel book1 = new PublicherModel();
            //var searchedbook = context.Books.FirstOrDefault(ww => ww.Title == book);
            var             searchedbook  = context.Books.FirstOrDefault(ww => ww.Title == book);
            var             bookauthor    = context.Authers.FirstOrDefault(ww => ww.AutherID == searchedbook.AutherID);
            var             bookpublisher = context.Publishers.FirstOrDefault(ww => ww.PublisherID == searchedbook.PublisherID);
            getbookbysearch bookmodel     = new getbookbysearch();

            bookmodel.Title         = searchedbook.Title;
            bookmodel.Image         = searchedbook.Image;
            bookmodel.NumberOfPage  = searchedbook.NumberOfPage;
            bookmodel.Price         = searchedbook.Price;
            bookmodel.PublishDate   = searchedbook.PublishDate;
            bookmodel.PublisherName = bookpublisher.Name;
            bookmodel.AuthorName    = bookauthor.Name;
            bookmodel.CategoryName  = (context.Categories.FirstOrDefault(ww => ww.CategoryID == searchedbook.CategoryID).CategoryName);
            return(bookmodel);
        }