Beispiel #1
0
 public NewsViewModel(T_News iNews)
 {
     Title = iNews.Title;
     Slug = iNews.Slug;
     AvataImageUrl = iNews.AvataImageUrl;
     IsHotNews = iNews.IsHotNews;
     ContentNews = iNews.ContentNews;
     Author = iNews.Author;
     PublishTime = iNews.PublishTime;
     Status = iNews.Status;
     ModifiedBy = iNews.ModifiedBy;
     ModifiedDate = iNews.ModifiedDate;
 }
Beispiel #2
0
        public ActionResult AddNew(FormCollection form, string Published)
        {
            // Upload Image
            HttpPostedFileBase file = Request.Files["ImageData"];
            string AvataURL = UploadAvatar(file);
            // Insert News
            T_News AddNews = new T_News();
            AddNews.Title = form["Title"].ToString();
            AddNews.Slug = form["Slug"].ToString();
            AddNews.ContentNews = form["ContentNews"];
            AddNews.CreatedDate = DateTime.Now;

            if(!string.IsNullOrEmpty(Published)) AddNews.Status = Constants.NEWS_STATUS_PUBLIC;
            else AddNews.Status = form["Status"].ToString();
            AddNews.AvataImageUrl = AvataURL;
            AddNews.CreatedBy = User.Identity.Name;
            AddNews.Author = form["Author"];
            if (string.IsNullOrEmpty(form["Title"].ToString()) || string.IsNullOrEmpty(form["Slug"].ToString()))
            {
                IEnumerable<T_Tag> CatList = _tagServices.GetByTaxonomyForDisplay(Utilities.Constants.TAXONOMY_CATEGORY);

                NewsViewModel model = new NewsViewModel(AddNews);
                model.CategoryList = CatList.ToList();
                model.MyCategoryList = new List<T_Tag>();
                // Get Slide_List again
                ModelState.AddModelError("Error", "Tiêu đề, Slug không được để trống");
                return View(model);
            }

            T_News MyNews = _newsServices.AddNewNewsAndReturn(AddNews);

            // Set News Category
            int SelectedCate = Convert.ToInt16(form["Category"]);
            _news_TagServices.AddNewNews_Tag(MyNews.ID, SelectedCate);

            // Insert Tag and News_Tags
            AddListTag(form["tags"].ToString(), MyNews.ID);

            return RedirectToAction("List", "News");
        }
Beispiel #3
0
 public MauThietKeViewModel(T_News iMauThietKe, T_Tag iCate)
 {
     MauThietKe = iMauThietKe;
     Cate = iCate;
 }