Esempio n. 1
0
        public static List <Products> GetListNotification(SearchProducts dto)
        {
            DataTable tabl = ConnectDb.ExecuteDataTableTask(Startup.ConnectionString, "SP_Products",
                                                            new string[] { "@flag", "@CurrentPage", "@ItemsPerPage" }, new object[] { "GetListNotification", dto.CurrentPage, dto.ItemsPerPage });

            if (tabl == null)
            {
                return(new List <Products>());
            }
            else
            {
                return((from r in tabl.AsEnumerable()
                        select new Products
                {
                    Id = (int)r["Id"],
                    Title = (string)r["Title"],
                    Alias = (string)((r["Alias"] == System.DBNull.Value) ? null : r["Alias"]),
                    CatId = (int)r["CatId"],
                    IntroText = (string)((r["IntroText"] == System.DBNull.Value) ? null : r["IntroText"]),
                    Status = (Boolean)r["Status"],
                    PublishUpShow = (string)((r["PublishUp"] == System.DBNull.Value) ? DateTime.Now.ToString("dd/MM/yyyy") : (string)((DateTime)r["PublishUp"]).ToString("dd/MM/yyyy")),
                    Featured = (Boolean)((r["Featured"] == System.DBNull.Value) ? null : r["Featured"]),
                    FeaturedHome = (Boolean)((r["FeaturedHome"] == System.DBNull.Value) ? null : r["FeaturedHome"]),
                    Images = (string)((r["Images"] == System.DBNull.Value) ? null : r["Images"]),
                    Ordering = (int?)((r["Ordering"] == System.DBNull.Value) ? null : r["Ordering"]),
                    Deleted = (Boolean)((r["Deleted"] == System.DBNull.Value) ? null : r["Deleted"]),
                    Price = (Decimal?)((r["Price"] == System.DBNull.Value) ?null : r["Price"]),
                }).ToList());
            }
        }
Esempio n. 2
0
        public static List <Products> GetListPagination(SearchProducts dto, string SecretId)
        {
            if (dto.CurrentPage <= 0)
            {
                dto.CurrentPage = 1;
            }
            if (dto.ItemsPerPage <= 0)
            {
                dto.ItemsPerPage = 15;
            }
            if (dto.Keyword == null)
            {
                dto.Keyword = "";
            }
            string  StartDate = DateTime.ParseExact(dto.ShowStartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyyMMdd");
            string  EndDate   = DateTime.ParseExact(dto.ShowEndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyyMMdd");
            string  str_sql   = "GetListPagination_Status";
            Boolean Status    = true;

            if (dto.Status == -1)
            {
                str_sql = "GetListPagination";
            }
            else if (dto.Status == 0)
            {
                Status = false;
            }
            var tabl = ConnectDb.ExecuteDataTableTask(Startup.ConnectionString, "SP_Products",
                                                      new string[] { "@flag", "@CurrentPage", "@ItemsPerPage", "@Keyword", "@CatId", "@IdCoQuan", "@AuthorId", "@StartDate", "@EndDate", "@CreatedBy", "@Status" },
                                                      new object[] { str_sql, dto.CurrentPage, dto.ItemsPerPage, dto.Keyword, dto.CatId, dto.IdCoQuan, dto.AuthorId, StartDate, EndDate, dto.CreatedBy, Status });

            if (tabl == null)
            {
                return(new List <Products>());
            }
            else
            {
                return((from r in tabl.AsEnumerable()
                        select new Products
                {
                    Id = (int)r["Id"],
                    Title = (string)r["Title"],
                    Alias = (string)((r["Alias"] == System.DBNull.Value) ? null : r["Alias"]),
                    CatId = (int)r["CatId"],
                    Category = (string)((r["Category"] == System.DBNull.Value) ? null : r["Category"]),
                    IntroText = (string)((r["IntroText"] == System.DBNull.Value) ? null : r["IntroText"]),
                    Status = (Boolean)r["Status"],
                    PublishUpShow = (string)((r["PublishUp"] == System.DBNull.Value) ? DateTime.Now.ToString("dd/MM/yyyy") : (string)((DateTime)r["PublishUp"]).ToString("dd/MM/yyyy")),
                    Featured = (Boolean)((r["Featured"] == System.DBNull.Value) ? null : r["Featured"]),
                    FeaturedHome = (Boolean)((r["FeaturedHome"] == System.DBNull.Value) ? null : r["FeaturedHome"]),
                    Images = (string)((r["Images"] == System.DBNull.Value) ? null : r["Images"]),
                    Ordering = (int?)((r["Ordering"] == System.DBNull.Value) ? null : r["Ordering"]),
                    Deleted = (Boolean)((r["Deleted"] == System.DBNull.Value) ? null : r["Deleted"]),
                    Price = (Decimal?)((r["Price"] == System.DBNull.Value) ?null : r["Price"]),
                    Ids = MyModels.Encode((int)r["Id"], SecretId)
                }).ToList());
            }
        }