Ejemplo n.º 1
0
        internal bool IsValid()
        {
            var fieldsAreSpecified = !string.IsNullOrEmpty(this.Name) && this.Name.Length >= 6 && this.OwnerId > 0;
            var doesOwnerExist     = DatabaseMediator.ExecuteScalar <int>("SELECT COUNT(*) FROM UserProfile WHERE UserId = @id", new { id = this.OwnerId }) == 1;

            return(fieldsAreSpecified && doesOwnerExist);
        }
Ejemplo n.º 2
0
        internal bool IsValid()
        {
            var fieldsAreSpecified = this.GameId != Guid.Empty && !string.IsNullOrEmpty(this.Platform) && this.PlayerId != Guid.Empty && this.StartTimeUtc > DateTime.MinValue;
            var doesGameExist      = DatabaseMediator.ExecuteScalar <int>("SELECT COUNT(*) FROM Game WHERE Id = @id", this.GameId) == 1;

            return(fieldsAreSpecified && doesGameExist);
        }
        public static int GetCurrentUserId(this ApiController c)
        {
            var userName = c.User.Identity.Name;

            if (!userNameToId.ContainsKey(userName))
            {
                var userId = DatabaseMediator.ExecuteScalar <int>("SELECT UserId FROM UserProfile WHERE UserName = @name", new { name = userName });
                userNameToId[userName] = userId;
            }

            return(userNameToId[userName]);
        }