Пример #1
0
        public ActionResult Blog(int id)
        {
            yackEntities ye   = new yackEntities();
            var          list = ye.Articls.Where(c => c.categoryId == id);

            ViewBag.categ = (ye.Category.Select(a => new ViewModels.viewCategory {
                categoryId = a.Id, categoryName = a.categoryName
            })).ToList();
            return(View(list));
        }
Пример #2
0
        public ActionResult Article(int id)
        {
            yackEntities ye     = new yackEntities();
            var          articl = ye.Articls.Where(c => c.Id == id).FirstOrDefault();

            ViewBag.categ = (ye.Category.Select(a => new ViewModels.viewCategory {
                categoryId = a.Id, categoryName = a.categoryName
            })).ToList();
            return(View(articl));
        }
Пример #3
0
        // GET: Admin
        public ActionResult Index()
        {
            yackEntities ye = new yackEntities();

            ViewBag.categ = ye.Category.Select(n => new SelectListItem
            {
                Value = n.Id.ToString(),
                Text  = n.categoryName
            }).ToList();
            return(View());
        }
Пример #4
0
 public ActionResult Category(Category categ)
 {
     if (ModelState.IsValid)
     {
         try
         {
             yackEntities ye = new yackEntities();
             ye.Category.Add(new Models.Category {
                 categoryName = categ.categoryName
             });
             ye.SaveChanges();
         }
         catch (Exception)
         {
             return(View());
         }
     }
     return(View());
 }
Пример #5
0
        public ActionResult Article(string cName, string cMessage, string cid)
        {
            yackEntities ye = new yackEntities();
            int          id; int.TryParse(cid, out id);

            if (id > 0 && cName != string.Empty && cMessage != string.Empty)
            {
                ye.VisitorComments.Add(new VisitorComments {
                    articleId = id, commentDate = DateTime.Now, visitorName = cName, comment = cMessage
                });
                ye.SaveChanges();
            }
            var articl = ye.Articls.Where(c => c.Id == id).FirstOrDefault();

            ViewBag.categ = (ye.Category.Select(a => new ViewModels.viewCategory {
                categoryId = a.Id, categoryName = a.categoryName
            })).ToList();
            return(View(articl));
        }
Пример #6
0
 public ActionResult Index(Articls article)
 {
     try
     {
         yackEntities ye = new yackEntities();
         ViewBag.categ = ye.Category.Select(n => new SelectListItem
         {
             Value = n.Id.ToString(),
             Text  = n.categoryName
         }).ToList();
         ye.Articls.Add(new Articls {
             articleDate = DateTime.Now, categoryId = article.categoryId, articleDetails = article.articleDetails, subject = article.subject
         });
         ye.SaveChanges();
         return(View());
     }
     catch (Exception)
     {
         return(View());
     }
 }