public ActionResult Edit(int id)
        {
            ViewBag.Type = "edit";

            if (id == null)
            {
                throw new SubjectNotFoundException();
            }

            Subjects subject = null;

            try
            {
                ViewBag.Teachers = new SelectList(usersService.FindAllTeachers(), "id_user", "full_name");
                ViewBag.Groups   = new SelectList(groupsService.FindAll, "id_group", "full_name");

                subject = subjectService.FindById(id);

                List <string> selectedGroups = new List <string>();

                foreach (Groups group in subject.Groups)
                {
                    selectedGroups.Add(Convert.ToString(group.id_group));
                }

                SubjectsViewModel viewModel = new SubjectsViewModel();
                viewModel.subject        = subject;
                viewModel.SelectedUser   = Convert.ToString(subject.id_user);
                viewModel.SelectedGroups = selectedGroups.ToArray();

                return(View(viewModel));
            }
            catch (SubjectNotFoundException ex)
            {
                TempData["Status"] = "invalid";
                TempData["Msg"]    = "Nie znaleziono przedmiotu!";
                return(RedirectToAction("List"));
            }
        }