示例#1
0
        // GET: Comments/Create
        public ActionResult Create()
        {
            var users = db.Users.ToList();
            var books = db.Books.ToList();

            var models = new ViewModels.Comments.Create(users, books);

            return(View(models));
        }
示例#2
0
        public ActionResult Create(ViewModels.Comments.Create model)
        {
            var comment = new Comments();

            comment.Created = DateTime.UtcNow.Ticks;
            comment.BookID  = model.selecedBookId;
            comment.UserID  = model.selectedUserId;
            comment.Comment = model.Comment;

            db.Comments.Add(comment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }