Beispiel #1
0
        public List <AuthorCLS> FilterAuthor(string data)
        {
            List <AuthorCLS> listAuthor = new List <AuthorCLS>();

            using (var db = new BlazorLibraryDBContext())
            {
                if (data != null || data == "--Selected One Item--")
                {
                    listAuthor = (from author in db.Authors
                                  join country in db.Countries
                                  on author.CountryId equals country.Id
                                  join gender in db.SexTypes
                                  on author.SexTypeId equals gender.Id
                                  where author.Active == 1 && author.Id == Convert.ToInt32(data)
                                  select new AuthorCLS
                    {
                        Id = author.Id,
                        Fullname = author.Username,
                        CountryName = country.CountryName,
                        SexTypeName = gender.SexTypeName,
                        Description = author.Description
                    }).ToList();
                }
                return(listAuthor);
            }
        }
        public List <BookTypeCLS> Filter(string data)
        {
            List <BookTypeCLS> bookList = new List <BookTypeCLS>();

            using (BlazorLibraryDBContext db = new BlazorLibraryDBContext())
            {
                if (data == null)
                {
                    bookList = (from bookType in db.BookTypes
                                where bookType.Active == 1
                                select new BookTypeCLS
                    {
                        Id = bookType.Id,
                        BookTypeName = bookType.BookTypeName,
                        Description = bookType.Description
                    }).ToList();
                }
                else
                {
                    bookList = (from bookType in db.BookTypes
                                where
                                bookType.Active == 1 &&
                                bookType.BookTypeName.Contains(data)
                                select new BookTypeCLS
                    {
                        Id = bookType.Id,
                        BookTypeName = bookType.BookTypeName,
                        Description = bookType.Description
                    }).ToList();
                }
            }
            return(bookList);
        }
Beispiel #3
0
        public List <CountryCLS> CountryList()
        {
            List <CountryCLS> listCountry = new List <CountryCLS>();

            using (var db = new BlazorLibraryDBContext())
            {
                listCountry = (from country in db.Countries
                               where country.Active == 1
                               select new CountryCLS
                {
                    Id = country.Id,
                    CountryName = country.CountryName
                }).ToList();
            }
            return(listCountry);
        }
        public List <BookTypeCLS> Get()
        {
            List <BookTypeCLS> bookList = new List <BookTypeCLS>();

            using (BlazorLibraryDBContext db = new BlazorLibraryDBContext())
            {
                bookList = (from bookType in db.BookTypes
                            where bookType.Active == 1
                            select new BookTypeCLS
                {
                    Id = bookType.Id,
                    BookTypeName = bookType.BookTypeName,
                    Description = bookType.Description
                }).ToList();
            }
            return(bookList);
        }
Beispiel #5
0
        public int DeleteData(string data)
        {
            int changeRow = 0;

            try
            {
                using (var db = new BlazorLibraryDBContext())
                {
                    Author aut = db.Authors.Where(p => p.Id == Convert.ToInt32(data)).First();
                    aut.Active = 0;
                    db.SaveChanges();
                    return(changeRow = 1);
                }
            }
            catch (Exception ex)
            {
                return(changeRow = 0);
            }
        }
Beispiel #6
0
        public List <AuthorCLS> Index()
        {
            List <AuthorCLS> listAuthor = new List <AuthorCLS>();

            using (var db = new BlazorLibraryDBContext())
            {
                listAuthor = (from author in db.Authors
                              join country in db.Countries
                              on author.CountryId equals country.Id
                              join gender in db.SexTypes
                              on author.SexTypeId equals gender.Id
                              where author.Active == 1
                              select new AuthorCLS
                {
                    Id = author.Id,
                    Fullname = author.Username,
                    CountryName = country.CountryName,
                    SexTypeName = gender.SexTypeName,
                    Description = author.Description
                }).ToList();
            }
            return(listAuthor);
        }