//GET: Create
        //UserFlashCard/Create
        //public ActionResult Create()
        //{
        //    return View();
        //}

        //Post: Create
        //UserFlashCard/Create



        public ActionResult Create(int id)
        {
            var model = new UserFlashCardCreate();

            model.FlashCardId = id;
            model.UserId      = User.Identity.GetUserId();
            //if (!ModelState.IsValid)
            //{
            //    return View(model);
            //}
            var service = CreateUserFlashCardService();

            service.CreateUserFlashCard(model);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public bool CreateUserFlashCard(UserFlashCardCreate model)
        {
            var entity =
                new UserFlashCard()

            {
                FlashCardId = model.FlashCardId,
                UserId      = model.UserId
            };

            using (var db = new ApplicationDbContext())
            {
                db.UserFlashCards.Add(entity);
                return(db.SaveChanges() == 1);
            }
        }