public ActionResult Save(Profession profession)
        {
            if (!ModelState.IsValid)
            {
                var categories = _context.Categories.ToList();
                var viewModel  = new ProfessionFormViewModel
                {
                    Categories = categories
                };


                return(View("ProfessionForm", viewModel));
            }


            if (profession.Id == 0)
            {
                _context.Professions.Add(profession);
            }
            else
            {
                var professionInDb = _context.Professions.Single(p => p.Id == profession.Id);

                professionInDb.Name          = profession.Name;
                professionInDb.Category      = profession.Category;
                professionInDb.Description   = profession.Description;
                professionInDb.CategoryId    = profession.CategoryId;
                professionInDb.Professionals = profession.Professionals;
            }

            _context.SaveChanges();


            return(RedirectToAction("Index", "Professions"));
        }
        public ActionResult New()
        {
            var categories = _context.Categories.ToList();
            var viewModel  = new ProfessionFormViewModel
            {
                Categories = categories
            };


            return(View("ProfessionForm", viewModel));
        }
        public ActionResult Edit(int id)
        {
            var profession = _context.Professions.SingleOrDefault(p => p.Id == id);

            if (profession == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new ProfessionFormViewModel
            {
                Profession = profession,
                Categories = _context.Categories.ToList()
            };

            return(View("ProfessionForm", viewModel));
        }