Example #1
0
        public ActionResult BlogDetail(string id)
        {
            var model = new CMS_NewsViewModel();

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    return(RedirectToAction("Index", "NotFound"));
                }
                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;
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "NotFound"));
            }
            return(View(model));
        }
Example #2
0
 public CMS_NewsModels GetDetail(string Id)
 {
     var model = _factory.GetDetail(Id);
     //if (model != null)
     //    model.ImageURL = Commons.HostImage + "News/" + model.ImageURL;
     return model;
 }
Example #3
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));
        }