Example #1
0
        public ActionResult AddNewLeague(string leagueName)
        {
            var leagueExists = _leagueRepository.DoesLeagueExist(leagueName);

            if (leagueExists)
            {
                return(CreateJsonError("En liga med dette navnet finnes allerede."));
            }

            var guid = Guid.NewGuid();

            try
            {
                using (var scope = new TransactionScope())
                {
                    var league = AddNewLeague(leagueName, guid);

                    AddCurrentUserToLeague(league);

                    scope.Complete();
                }
            }
            catch (Exception)
            {
                return(CreateJsonError("Oppretting av liga feilet."));
            }

            return(Content(guid.ToString()));
        }