Beispiel #1
0
        public ActionResult Create(Article article)
        {
            if (ModelState.IsValid)
            {
                article.CreatedDate = DateTime.Now;
                article.LastModifiedDate = DateTime.Now;
                db.Articles.Add(article);
                db.SaveChanges();

                dataManagement.UserRatingRepository.AddUserRating(article.UserId, article.CategoryId, _ArticleValue);

                return RedirectToAction("Index");
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", article.CategoryId);
            ViewBag.UserId = WebSecurity.CurrentUserId;
            return View(article);
        }
Beispiel #2
0
 public ActionResult Edit(Article article)
 {
     if (ModelState.IsValid)
     {
         db.Entry(article).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", article.CategoryId);
     return View(article);
 }