Beispiel #1
0
        public ActionResult Create(FlashCardCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var service = new FlashCardService();

            service.CreateFlashCard(model);

            return(RedirectToAction("Index"));
        }
        public bool CreateFlashCard(FlashCardCreate model)
        {
            var entity =
                new FlashCard()

            {
                FlashCardId  = model.FlashCardId,
                Word         = model.Word,
                Definition   = model.Definition,
                PartOfSpeech = model.PartOfSpeech
            };

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