// GET: FormalCategories/Create
        public ActionResult Create()
        {
            var formalTypes = db.FormalTypes.ToList();
            var model       = new CreateFormalCategoryViewModel()
            {
                FormalTypes = formalTypes,
            };

            return(View(model));
        }
        public ActionResult Create(CreateFormalCategoryViewModel model)
        {
            model.FormalTypes = db.FormalTypes.ToList();
            var formalCategory = new FormalCategory()
            {
                Name = model.Name,
                Type = model.FormalTypes.FirstOrDefault(type => type.Id == model.SelectedFormalTypeId)
            };

            if (ModelState.IsValid)
            {
                db.FormalCategories.Add(formalCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }