public ActionResult AddGroup(int? compid)
        {
            if (compid == null)
            {
                AddApplicationMessage("Nebyl uveden identifikátor soutěže", MessageSeverity.Danger);
                return RedirectToAction("Admin", "Competitions");
            }

            var comp = unitOfWork.CompetitionRepository.GetByID(compid);
            if (comp == null)
            {
                AddApplicationMessage("Id neodpovídá žádné soutěži", MessageSeverity.Danger);
                return RedirectToAction("Admin", "Competitions");
            }

            var model = new AddGroupViewModel()
            {
                competition = comp
            };

            return View(model);
        }
        public ActionResult AddGroup(AddGroupViewModel model)
        {
            if(ModelState.IsValid)
            {
                var group = new Groups()
                {
                    Competition = model.compid,
                    Name = model.name,
                    Playoff = model.playoff ? 1 : 0
                };

                unitOfWork.GroupRepository.Insert(group);
                unitOfWork.Save();
                Log(JsonConvert.SerializeObject(model), LogEvent.GroupAdd.ToString(), group.ID, "group");
                AddApplicationMessage("Skupina byla přidána", MessageSeverity.Success);

                return RedirectToAction("Admin","Competitions");
            }
            model.competition = unitOfWork.CompetitionRepository.GetByID(model.compid);

            AddApplicationMessage("Skupinu se nepodařilo uložit, zkontrolujte formulář", MessageSeverity.Danger);

            return View(model);
        }
        public ActionResult EditGroup(AddGroupViewModel model)
        {
            var group = unitOfWork.GroupRepository.GetByID(model.groupid);
            if (group == null)
            {
                AddApplicationMessage("Skupina nebyla nalezena", MessageSeverity.Danger);
            }
            else
            {
                group.Name = model.name;
                group.Playoff = model.playoff ? 1 : 0;

                unitOfWork.GroupRepository.Update(group);
                unitOfWork.Save();
                Log(JsonConvert.SerializeObject(model), LogEvent.GroupEdit.ToString(), group.ID, "group");
                AddApplicationMessage("Skupina byla upravena", MessageSeverity.Success);
            }

            model.competition = group.Competitions;

            return RedirectToAction("Admin", "Competitions");
        }
        public ActionResult EditGroup(int? groupid)
        {
            if (groupid == null)
            {
                AddApplicationMessage("Nebylo uvedeno ID skupiny", MessageSeverity.Danger);
                return RedirectToAction("Admin", "Competitions");
            }

            var group = unitOfWork.GroupRepository.GetByID(groupid);
            if (group == null)
            {
                AddApplicationMessage("Skupina nebyla nalezena", MessageSeverity.Danger);
                return RedirectToAction("Admin", "Competitions");
            }

            var model = new AddGroupViewModel()
            {
                groupid = (int)groupid,
                name = group.Name,
                playoff = group.Playoff == 1 ? true : false,
                compid = group.Competition,
                competition = group.Competitions
            };
            return View("AddGroup", model);
        }