public IHttpActionResult Update(LeagueUnsecureViewModel model)
        {
            _leaguesManager.Update(model);

            return Json(model);
        }
 public void Create(LeagueUnsecureViewModel model)
 {
     _leaguesRepository.Create(model);
 }
        private LeagueAccessStatus GetAccess(LeagueUnsecureViewModel league, IOwinContext context, string currentUserId)
        {
            if (IsAdmin())
                return LeagueAccessStatus.Admin;

            if (string.IsNullOrEmpty(league.VkGroup))
            {
                return league.Admins.Any(x => x.Id == currentUserId)
                    ? LeagueAccessStatus.Editor
                    : LeagueAccessStatus.Member;
            }

            var loginInfo = context.Authentication.GetExternalLoginInfoAsync();
            if (loginInfo == null || loginInfo.Result == null)
                return LeagueAccessStatus.Undefined;

            var vkUserIdClaim = loginInfo.Result.ExternalIdentity.Claims.FirstOrDefault(c => c.Type == "VkUserId");
            if (vkUserIdClaim == null)
                return LeagueAccessStatus.Undefined;

            var api = new VkApi();
            long vkUserId;
            try
            {
                vkUserId = long.Parse(vkUserIdClaim.Value);
            }
            catch (Exception)
            {
                return LeagueAccessStatus.Undefined;
            }

            var response = api.Groups.IsMember("spbdiyfootball", vkUserId, new long[] { vkUserId }, false);
            if (!response[0].Member)
                return LeagueAccessStatus.Undefined;

            return league.Admins.Any(x => x.Id == currentUserId)
                ? LeagueAccessStatus.Editor
                : LeagueAccessStatus.Member;
        }