コード例 #1
0
        public bool FutureReadingCreate(FutureReadingCreate model)
        {
            var entity =
                new FutureReading()
            {
                FutureReadingID = model.FutureReadingID,
                UserID          = _userID,
                BookID          = model.BookID,
                Title           = model.Title,
                Author          = model.Author,
                Notes           = model.Notes,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.FutureReading.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #2
0
        //this all relates to the create MODEL
        public ActionResult Create(FutureReadingCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateFutureReadingService();

            //actually from service
            if (service.FutureReadingCreate(model))
            {
                TempData["SaveResult"] = "Your Book was added.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Book could not be added.");

            return(View(model));
        }