Example #1
0
        public List <CategoryByCategory> GetListCategory()
        {
            var _factory = new CMSCategoriesFactory();
            //var data = _factory.GetList().Where(x => !string.IsNullOrEmpty(x.ParentId)).Select(x => new SelectListItem
            //{
            //    Value = x.Id,
            //    Text = x.CategoryName,
            //}).ToList();
            //return data;
            var models = new List <CategoryByCategory>();
            var data   = _factory.GetList();

            if (data != null)
            {
                var groupCate = data.Where(x => string.IsNullOrEmpty(x.ParentId)).ToList();
                if (groupCate != null)
                {
                    groupCate.ForEach(x =>
                    {
                        var model      = new CategoryByCategory();
                        model.id       = x.Id;
                        model.text     = x.CategoryName.ToUpper();
                        model.children = data.Where(y => !string.IsNullOrEmpty(y.ParentId) && y.ParentId.Equals(x.Id))
                                         .Select(z => new CategoryChildren
                        {
                            id   = z.Id,
                            text = z.CategoryName
                        }).ToList();
                        models.Add(model);
                    });
                }
            }

            return(models);
        }
Example #2
0
        public List <SelectListItem> GetListCategorySelectItem()
        {
            var _factory = new CMSCategoriesFactory();
            var data     = _factory.GetList().Select(x => new SelectListItem
            {
                Value = x.Id,
                Text  = x.CategoryName,
            }).ToList();

            return(data);
        }
Example #3
0
        public ActionResult LoadGrid()
        {
            var model = _factory.GetList();

            model.ForEach(x =>
            {
                x.sStatus          = x.IsActive ? "Kích hoạt" : "Chưa kích hoạt";
                x.sProductTypeCode = x.ProductTypeCode == (int)Commons.EProductType.Product ? "Sản phẩm" : "Dịch vụ";
            });
            return(PartialView("_ListData", model));
        }
Example #4
0
        // GET: Clients/Home
        public ActionResult Index()
        {
            try
            {
                ProductViewModels model = new ProductViewModels();

                //Company
                model.Company = _facCom.GetList().FirstOrDefault();

                //Category
                model.ListCate = _facCate.GetList().Where(o => o.ProductTypeCode == (int)Commons.EProductType.Procudure).OrderByDescending(x => x.CreatedDate).Skip(0).Take(3).ToList();

                //Product
                var productType = (byte)Commons.EProductType.Product;
                model.ListProduct = _fac.GetList(productType).Where(o => !string.IsNullOrEmpty(o.ImageURL)).OrderByDescending(x => x.CreatedDate).Skip(0).Take(8).ToList();

                //Procedures
                model.ListProcedures = _facProce.GetList().OrderBy(o => o.CreatedDate).Skip(0).Take(3).ToList();
                //News
                model.ListNews = _facNews.GetList().OrderByDescending(x => x.CreatedDate).Skip(0).Take(3).ToList();
                if (model.ListNews != null && model.ListNews.Any())
                {
                    model.ListNews.ForEach(x =>
                    {
                        if (!string.IsNullOrEmpty(x.ImageURL))
                        {
                            x.ImageURL = "~/Uploads/News/" + x.ImageURL;
                        }
                    });
                }

                model.ListEmployee = _facEmp.GetList().OrderBy(o => o.CreatedDate).Skip(0).Take(10).ToList();
                if (model.ListEmployee != null)
                {
                    model.ListEmployee.ForEach(o =>
                    {
                        o.ImageURL = !string.IsNullOrEmpty(o.ImageURL) ? Commons._PublicImages + "Employees/" + o.ImageURL : Commons._ImageDefault;
                    });
                }

                model.LstDiscount = _facDis.GetList(true);

                return(View(model));
            }
            catch (Exception ex)
            {
                // NSLog.Logger.Error("Index: ", ex);
                return(new HttpStatusCodeResult(400, ex.Message));
            }
        }
Example #5
0
        public ActionResult LoadGrid()
        {
            var model = _factory.GetList();

            model.ForEach(x =>
            {
                x.sStatus = x.IsActive ? "Kích hoạt" : "Chưa kích hoạt";
                if (!string.IsNullOrEmpty(x.ImageURL))
                {
                    x.ImageURL = Commons.HostImage + "Categories/" + x.ImageURL;
                }
            });
            return(PartialView("_ListData", model));
        }
Example #6
0
        public List <SelectListItem> GetListCateSelectItem()
        {
            var _factory = new CMSCategoriesFactory();
            List <SelectListItem> data = null;

            var listCate = _factory.GetList();

            if (listCate != null)
            {
                data = listCate.Select(x => new SelectListItem
                {
                    Value = x.Id,
                    Text  = x.CategoryName,
                }).ToList();
            }
            return(data);
        }
Example #7
0
        // GET: Clients/About
        public ActionResult Index()
        {
            var model = new CMS_AboutViewModels();

            try
            {
                model.Categories = _facCate.GetList().Where(x => x.ProductTypeCode == (int)Commons.EProductType.Procudure).OrderByDescending(x => x.CreatedDate).Skip(0).Take(3).ToList();
                model.Employees  = _facEmp.GetList().OrderByDescending(x => x.CreatedDate).Skip(0).Take(3).ToList();
                if (model.Employees != null)
                {
                    model.Employees.ForEach(o =>
                    {
                        o.ImageURL = !string.IsNullOrEmpty(o.ImageURL) ? Commons._PublicImages + "Employees/" + o.ImageURL : "";
                    });
                }
                model.LstDiscount = _facDis.GetList(true);
            }
            catch (Exception ex)
            {
                NSLog.Logger.Error("About Index", ex);
            }
            return(View(model));
        }
Example #8
0
        public ActionResult NewsDetail(string id)
        {
            var model = new CMS_NewsViewModel();

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    return(RedirectToAction("Index", "NotFound", new { area = "Clients" }));
                }
                else
                {
                    var data = _fac.GetDetail(id);
                    if (data != null)
                    {
                        if (!string.IsNullOrEmpty(data.ImageURL))
                        {
                            data.ImageURL = Commons.HostImage + "News/" + data.ImageURL;
                        }
                    }

                    model.CMS_News    = data;
                    model.ListNewsNew = _fac.GetList().OrderByDescending(x => x.CreatedDate).Skip(0).Take(2).ToList();
                    if (model.ListNewsNew != null && model.ListNewsNew.Any())
                    {
                        model.ListNewsNew.ForEach(x =>
                        {
                            if (!string.IsNullOrEmpty(x.ImageURL))
                            {
                                x.ImageURL = Commons.HostImage + "News/" + x.ImageURL;
                            }
                            else
                            {
                                x.ImageURL = Commons.Image870_500;
                            }
                        });
                    }
                    //For categories
                    model.ListCate = _facCate.GetList().OrderByDescending(x => x.CreatedDate).Skip(0).Take(5).ToList();
                    if (model.ListCate != null)
                    {
                        model.ListCate.ForEach(x =>
                        {
                            if (!string.IsNullOrEmpty(x.ImageURL))
                            {
                                x.ImageURL = Commons.HostImage + "News/" + x.ImageURL;
                            }
                            else
                            {
                                x.ImageURL = Commons.Image870_500;
                            }
                        });
                    }
                    //For Product
                    model.ListProduct = _facPro.GetList().OrderByDescending(x => x.CreatedDate).Skip(0).Take(5).ToList();
                    if (model.ListProduct != null)
                    {
                        model.ListProduct.ForEach(x =>
                        {
                            if (!string.IsNullOrEmpty(x.ImageURL))
                            {
                                x.ImageURL = Commons.HostImage + "News/" + x.ImageURL;
                            }
                            else
                            {
                                x.ImageURL = Commons.Image870_500;
                            }
                        });
                    }
                    //For company infor
                    model.CompanyInfor = _facCom.GetInfor();
                    if (model.CompanyInfor == null)
                    {
                        model.CompanyInfor = new CMS_DTO.CMSCompany.CMS_CompanyModels();
                    }
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "NotFound", new { area = "Clients" }));
            }
            return(View(model));
        }
Example #9
0
        // GET: Clients/Home
        public ActionResult Index()
        {
            try
            {
                ProductViewModels model = new ProductViewModels();

                //Company
                model.Company = _facCom.GetList().FirstOrDefault();

                //Category
                model.ListCate = _facCate.GetList().OrderByDescending(x => x.CreatedDate).Skip(0).Take(4).ToList();
                if (model.ListCate != null && model.ListCate.Any())
                {
                    model.ListCate.ForEach(x =>
                    {
                        if (!string.IsNullOrEmpty(x.ImageURL))
                        {
                            x.ImageURL = "~/Uploads/Categories/" + x.ImageURL;
                        }
                    });
                }

                //Product
                model.ListProduct = _fac.GetList().OrderByDescending(x => x.CreatedDate).Skip(0).Take(8).ToList();
                var dataImage = _fac.GetListImage();
                if (model.ListProduct != null && model.ListProduct.Any())
                {
                    model.ListProduct.ForEach(x =>
                    {
                        var _Image = dataImage.FirstOrDefault(z => z.ProductId.Equals(x.Id));
                        if (_Image != null)
                        {
                            x.ImageURL = _Image.ImageURL;
                            if (!string.IsNullOrEmpty(x.ImageURL))
                            {
                                x.ImageURL = "~/Uploads/Products/" + x.ImageURL;
                            }
                            else
                            {
                                x.ImageURL = "";
                            }
                        }
                    });
                }

                //News
                model.ListNews = _facNews.GetList().OrderByDescending(x => x.CreatedDate).Skip(0).Take(3).ToList();
                if (model.ListNews != null && model.ListNews.Any())
                {
                    model.ListNews.ForEach(x =>
                    {
                        if (!string.IsNullOrEmpty(x.ImageURL))
                        {
                            x.ImageURL = "~/Uploads/News/" + x.ImageURL;
                        }
                    });
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                // NSLog.Logger.Error("Index: ", ex);
                return(new HttpStatusCodeResult(400, ex.Message));
            }
        }