コード例 #1
0
        public ActionResult Create(WordCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.RootName is null)
            {
                return(View(model));
            }

            var  service    = new WordService();
            bool isRootInDb = service.RootIsInDb(model);

            if (isRootInDb == true)
            {
                service.CreateWord(model);

                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "The root you are trying to add does not seem to be in the database. Please enter the root seperately and return to add the word here.");
                return(View(model));
            }
        }