From 4beacdeecf38c549bea262b2df233904976b646d Mon Sep 17 00:00:00 2001 From: mpanowicz Date: Fri, 22 Apr 2016 22:35:21 +0200 Subject: [PATCH 001/126] Menu fix --- RabinChess.Web/src/scripts/components/layout/Menu.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/layout/Menu.jsx b/RabinChess.Web/src/scripts/components/layout/Menu.jsx index 0d33816..3628caf 100644 --- a/RabinChess.Web/src/scripts/components/layout/Menu.jsx +++ b/RabinChess.Web/src/scripts/components/layout/Menu.jsx @@ -44,9 +44,9 @@ class Menu extends React.Component { * @returns {div} Div containing menu */ render() { - let rows = menuElements.map((elem) => { + let rows = menuElements.map((elem, i) => { return ( - + )}); return ( From 0eb09fde2d42f07a49f4ca0cde3595a0fd76e2a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Sun, 24 Apr 2016 12:33:18 +0200 Subject: [PATCH 002/126] Initial database schema project --- .../RabinChess.Server.API/Web.config | 14 +++++++++++ .../RabinChess.Server.Database/App.config | 17 ++++++++++++++ .../Entities/Game.cs | 23 +++++++++++++++++++ .../Entities/GameTag.cs | 20 ++++++++++++++++ .../Entities/User.cs | 22 ++++++++++++++++++ .../RabinChess.Server.Database.csproj | 17 ++++++++++++++ .../RubinChessContext.cs | 17 ++++++++++++++ .../packages.config | 4 ++++ .../packages/repositories.config | 1 + 9 files changed, 135 insertions(+) create mode 100644 RabinChess.Server/RabinChess.Server.Database/App.config create mode 100644 RabinChess.Server/RabinChess.Server.Database/Entities/Game.cs create mode 100644 RabinChess.Server/RabinChess.Server.Database/Entities/GameTag.cs create mode 100644 RabinChess.Server/RabinChess.Server.Database/Entities/User.cs create mode 100644 RabinChess.Server/RabinChess.Server.Database/RubinChessContext.cs create mode 100644 RabinChess.Server/RabinChess.Server.Database/packages.config diff --git a/RabinChess.Server/RabinChess.Server.API/Web.config b/RabinChess.Server/RabinChess.Server.API/Web.config index 1a89eac..3ef5215 100644 --- a/RabinChess.Server/RabinChess.Server.API/Web.config +++ b/RabinChess.Server/RabinChess.Server.API/Web.config @@ -4,6 +4,20 @@ http://go.microsoft.com/fwlink/?LinkId=301879 --> + + +
+ + + + + + + + + + + diff --git a/RabinChess.Server/RabinChess.Server.Database/App.config b/RabinChess.Server/RabinChess.Server.Database/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Database/Entities/Game.cs b/RabinChess.Server/RabinChess.Server.Database/Entities/Game.cs new file mode 100644 index 0000000..6a5eb03 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Entities/Game.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace RubinChess.Server.Database.Entities +{ + public class Game + { + [Key] + public Guid Id { get; set; } + + public User User { get; set; } + + [ForeignKey("User"), Required] + public int UserId { get; set; } + + [Required] + public string GameNotation { get; set; } + + public virtual List Tags { get; set; } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Database/Entities/GameTag.cs b/RabinChess.Server/RabinChess.Server.Database/Entities/GameTag.cs new file mode 100644 index 0000000..2614669 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Entities/GameTag.cs @@ -0,0 +1,20 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace RubinChess.Server.Database.Entities +{ + public class GameTag + { + public Game Game { get; set; } + + [Key, ForeignKey("Game"), Column(Order = 1)] + public Guid GameId { get; set; } + + [Key, Column(Order = 2)] + public string Name { get; set; } + + [Required] + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Database/Entities/User.cs b/RabinChess.Server/RabinChess.Server.Database/Entities/User.cs new file mode 100644 index 0000000..87cca0c --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Entities/User.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace RubinChess.Server.Database.Entities +{ + public class User + { + [Key] + public int Id { get; set; } + + [MinLength(5), MaxLength(25), Required] + public string UserName { get; set; } + + [Required] + public string PasswordHash { get; set; } + + [Required] + public string Email { get; set; } + + public virtual List Games { get; set; } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Database/RabinChess.Server.Database.csproj b/RabinChess.Server/RabinChess.Server.Database/RabinChess.Server.Database.csproj index 5583d8d..69de85b 100644 --- a/RabinChess.Server/RabinChess.Server.Database/RabinChess.Server.Database.csproj +++ b/RabinChess.Server/RabinChess.Server.Database/RabinChess.Server.Database.csproj @@ -30,7 +30,16 @@ 4 + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + True + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + True + + @@ -39,7 +48,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.sln b/RabinChess.Server/RabinChess.Server.sln index 27c0981..d5205eb 100644 --- a/RabinChess.Server/RabinChess.Server.sln +++ b/RabinChess.Server/RabinChess.Server.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabinChess.Server.Database" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabinChess.Server.API", "RabinChess.Server.API\RabinChess.Server.API.csproj", "{81411047-62C5-46E3-88A4-B16F8688052B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabinChess.Server.DataStructures", "RabinChess.Server.DataStructures\RabinChess.Server.DataStructures.csproj", "{3D934DC5-2D2B-496C-AA69-17BC7A7D07A5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {81411047-62C5-46E3-88A4-B16F8688052B}.Debug|Any CPU.Build.0 = Debug|Any CPU {81411047-62C5-46E3-88A4-B16F8688052B}.Release|Any CPU.ActiveCfg = Release|Any CPU {81411047-62C5-46E3-88A4-B16F8688052B}.Release|Any CPU.Build.0 = Release|Any CPU + {3D934DC5-2D2B-496C-AA69-17BC7A7D07A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D934DC5-2D2B-496C-AA69-17BC7A7D07A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D934DC5-2D2B-496C-AA69-17BC7A7D07A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D934DC5-2D2B-496C-AA69-17BC7A7D07A5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RabinChess.Server/packages/repositories.config b/RabinChess.Server/packages/repositories.config index cfe9455..ab1e46e 100644 --- a/RabinChess.Server/packages/repositories.config +++ b/RabinChess.Server/packages/repositories.config @@ -2,4 +2,5 @@ + From c2978ecd187703c2239eef8beade71760647a695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Tue, 3 May 2016 15:44:19 +0200 Subject: [PATCH 071/126] Added game retriever --- .../RabinChess.Server.Logic/App.config | 17 +++++++++ .../RabinChess.Server.Logic/GamesRetriever.cs | 35 +++++++++++++++++++ .../RabinChess.Server.Logic.csproj | 18 ++++++++++ .../RabinChess.Server.Logic/packages.config | 4 +++ 4 files changed, 74 insertions(+) create mode 100644 RabinChess.Server/RabinChess.Server.Logic/App.config create mode 100644 RabinChess.Server/RabinChess.Server.Logic/GamesRetriever.cs create mode 100644 RabinChess.Server/RabinChess.Server.Logic/packages.config diff --git a/RabinChess.Server/RabinChess.Server.Logic/App.config b/RabinChess.Server/RabinChess.Server.Logic/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic/GamesRetriever.cs b/RabinChess.Server/RabinChess.Server.Logic/GamesRetriever.cs new file mode 100644 index 0000000..6195877 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic/GamesRetriever.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.Linq; +using RabinChess.Server.DataStructures; +using RubinChess.Server.Database; +using RubinChess.Server.Database.Entities; + +namespace RubinChess.Server.Logic +{ + public class GamesRetriever + { + public List GetGames(int userId) + { + var gameListItems = new List(); + using (var ctx = new RubinChessContext()) + { + List games = ctx.Users.FirstOrDefault(user => user.Id == userId).Games; + games.ForEach(game => gameListItems.Add(new GameListItemVM{Id = game.Id, Name = game.Name, Tags = TagsStringCreator(game.Tags)})); + } + return gameListItems; + } + + private static string TagsStringCreator(List tags) + { + string tagsString = string.Empty; + + tagsString += tags.FirstOrDefault(tag => tag.Name == "White").Value; + tagsString += " vs. "; + tagsString += tags.FirstOrDefault(tag => tag.Name == "Black").Value; + tagsString += " | "; + tagsString += tags.FirstOrDefault(tag => tag.Name == "Event").Value; + + return tagsString; + } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic/RabinChess.Server.Logic.csproj b/RabinChess.Server/RabinChess.Server.Logic/RabinChess.Server.Logic.csproj index 31b61fa..5f1e869 100644 --- a/RabinChess.Server/RabinChess.Server.Logic/RabinChess.Server.Logic.csproj +++ b/RabinChess.Server/RabinChess.Server.Logic/RabinChess.Server.Logic.csproj @@ -30,7 +30,16 @@ 4 + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + True + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + True + + @@ -39,6 +48,7 @@ + @@ -46,6 +56,14 @@ {28073fba-2df2-4df6-a519-e4ddff3cded9} RabinChess.Server.Database + + {3d934dc5-2d2b-496c-aa69-17bc7a7d07a5} + RabinChess.Server.DataStructures + + + + +
- + @@ -45,6 +45,14 @@ + + + + + + + + diff --git a/RabinChess.Server/RabinChess.Server.API/packages.config b/RabinChess.Server/RabinChess.Server.API/packages.config index f2ea303..7d2ac0d 100644 --- a/RabinChess.Server/RabinChess.Server.API/packages.config +++ b/RabinChess.Server/RabinChess.Server.API/packages.config @@ -1,8 +1,18 @@  + + + + + + + + + + \ No newline at end of file From 54a9faec6b334187a6780e45ada625a28bf07128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Tue, 3 May 2016 21:00:43 +0200 Subject: [PATCH 078/126] Added user manager --- .../RabinChess.Server.Logic/ContextFactory.cs | 10 ++- .../Contexts/IUserContext.cs | 13 ++++ .../Contexts/UserContext.cs | 40 +++++++++++ .../Interactions/IUserManager.cs | 13 ++++ .../Interactions/UserManager.cs | 69 +++++++++++++++++++ .../RabinChess.Server.Logic.csproj | 4 ++ 6 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 RabinChess.Server/RabinChess.Server.Logic/Contexts/IUserContext.cs create mode 100644 RabinChess.Server/RabinChess.Server.Logic/Contexts/UserContext.cs create mode 100644 RabinChess.Server/RabinChess.Server.Logic/Interactions/IUserManager.cs create mode 100644 RabinChess.Server/RabinChess.Server.Logic/Interactions/UserManager.cs diff --git a/RabinChess.Server/RabinChess.Server.Logic/ContextFactory.cs b/RabinChess.Server/RabinChess.Server.Logic/ContextFactory.cs index 569965e..16ab248 100644 --- a/RabinChess.Server/RabinChess.Server.Logic/ContextFactory.cs +++ b/RabinChess.Server/RabinChess.Server.Logic/ContextFactory.cs @@ -5,16 +5,24 @@ namespace RubinChess.Server.Logic { public static class ContextFactory { - public static IGamesContext GamesContext { get; set; } + private static IUserContext UserContext { get; set; } + + private static IGamesContext GamesContext { get; set; } static ContextFactory() { GamesContext = new GamesContext(new GamesRetriever()); + UserContext = new UserContext(new UserManager()); } public static IGamesContext GetGamesContext() { return GamesContext; } + + public static IUserContext GetUserContext() + { + return UserContext; + } } } \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic/Contexts/IUserContext.cs b/RabinChess.Server/RabinChess.Server.Logic/Contexts/IUserContext.cs new file mode 100644 index 0000000..3d88450 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic/Contexts/IUserContext.cs @@ -0,0 +1,13 @@ +using RubinChess.Server.Database.Entities; + +namespace RubinChess.Server.Logic.Contexts +{ + public interface IUserContext + { + int AddUser(User user); + bool DeleteUser(int userId); + int UpdateUser(User user); + User GetUser(int userId); + User GetUser(string userName); + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic/Contexts/UserContext.cs b/RabinChess.Server/RabinChess.Server.Logic/Contexts/UserContext.cs new file mode 100644 index 0000000..ebfcbf9 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic/Contexts/UserContext.cs @@ -0,0 +1,40 @@ +using RubinChess.Server.Database.Entities; +using RubinChess.Server.Logic.Interactions; + +namespace RubinChess.Server.Logic.Contexts +{ + public class UserContext : IUserContext + { + private IUserManager UserManager { get; set; } + + public UserContext(IUserManager userManager) + { + UserManager = userManager; + } + + public int AddUser(User user) + { + return UserManager.AddUser(user); + } + + public bool DeleteUser(int userId) + { + return UserManager.DeleteUser(userId); + } + + public int UpdateUser(User user) + { + return UserManager.UpdateUser(user); + } + + public User GetUser(int userId) + { + return UserManager.GetUser(userId); + } + + public User GetUser(string userName) + { + return UserManager.GetUser(userName); + } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic/Interactions/IUserManager.cs b/RabinChess.Server/RabinChess.Server.Logic/Interactions/IUserManager.cs new file mode 100644 index 0000000..9ddc284 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic/Interactions/IUserManager.cs @@ -0,0 +1,13 @@ +using RubinChess.Server.Database.Entities; + +namespace RubinChess.Server.Logic.Interactions +{ + public interface IUserManager + { + int AddUser(User user); + bool DeleteUser(int userId); + int UpdateUser(User user); + User GetUser(int userId); + User GetUser(string userName); + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic/Interactions/UserManager.cs b/RabinChess.Server/RabinChess.Server.Logic/Interactions/UserManager.cs new file mode 100644 index 0000000..90a335e --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic/Interactions/UserManager.cs @@ -0,0 +1,69 @@ +using System.Data.Entity; +using System.Linq; +using RubinChess.Server.Database; +using RubinChess.Server.Database.Entities; + +namespace RubinChess.Server.Logic.Interactions +{ + public class UserManager : IUserManager + { + public int AddUser(User user) + { + int newUserId; + using (var ctx = new RubinChessContext()) + { + User newUser = ctx.Users.Add(user); + ctx.SaveChanges(); + newUserId = newUser.Id; + } + return newUserId; + } + + public bool DeleteUser(int userId) + { + using (var ctx = new RubinChessContext()) + { + ctx.Users.Remove(ctx.Users.FirstOrDefault(user => user.Id == userId)); + ctx.SaveChanges(); + } + return true; + } + + public int UpdateUser(User user) + { + int userId; + using (var ctx = new RubinChessContext()) + { + var existingUser = ctx.Users.FirstOrDefault(dbUser => dbUser.Id == user.Id); + existingUser.Email = user.Email; + existingUser.FirstName = user.FirstName; + existingUser.LastName = user.LastName; + existingUser.PasswordHash = user.PasswordHash; + existingUser.UserName = user.UserName; + ctx.SaveChanges(); + userId = existingUser.Id; + } + return userId; + } + + public User GetUser(int userId) + { + User user; + using (var ctx = new RubinChessContext()) + { + user = ctx.Users.Include(dbUser => dbUser.Games).FirstOrDefault(dbUser => dbUser.Id == userId); + } + return user; + } + + public User GetUser(string userName) + { + User user; + using (var ctx = new RubinChessContext()) + { + user = ctx.Users.Include(dbUser => dbUser.Games).FirstOrDefault(dbUser => dbUser.UserName == userName); + } + return user; + } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic/RabinChess.Server.Logic.csproj b/RabinChess.Server/RabinChess.Server.Logic/RabinChess.Server.Logic.csproj index dc92870..820c3d8 100644 --- a/RabinChess.Server/RabinChess.Server.Logic/RabinChess.Server.Logic.csproj +++ b/RabinChess.Server/RabinChess.Server.Logic/RabinChess.Server.Logic.csproj @@ -51,8 +51,12 @@ + + + + From 89d046b04c7a0524e9eedd5777d97a3fb71dad0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Tue, 3 May 2016 21:01:26 +0200 Subject: [PATCH 079/126] Added api authentication --- .../App_Start/Startup.Auth.cs | 30 ++++++ .../Providers/ApplicationOAuthProvider.cs | 102 ++++++++++++++++++ .../RabinChess.Server.API.csproj | 10 ++ .../Security/PasswordHasher.cs | 25 +++++ .../RabinChess.Server.API/Stores/UserStore.cs | 24 +++-- .../RabinChess.Server.API/packages.config | 4 +- 6 files changed, 185 insertions(+), 10 deletions(-) create mode 100644 RabinChess.Server/RabinChess.Server.API/Providers/ApplicationOAuthProvider.cs create mode 100644 RabinChess.Server/RabinChess.Server.API/Security/PasswordHasher.cs diff --git a/RabinChess.Server/RabinChess.Server.API/App_Start/Startup.Auth.cs b/RabinChess.Server/RabinChess.Server.API/App_Start/Startup.Auth.cs index b9311e9..8024718 100644 --- a/RabinChess.Server/RabinChess.Server.API/App_Start/Startup.Auth.cs +++ b/RabinChess.Server/RabinChess.Server.API/App_Start/Startup.Auth.cs @@ -1,7 +1,13 @@ using System; using Microsoft.AspNet.Identity; +using Microsoft.Owin; +using Microsoft.Owin.Cors; +using Microsoft.Owin.Security.Cookies; using Microsoft.Owin.Security.OAuth; +using Owin; using RabinChess.Server.API.Models; +using RabinChess.Server.API.Providers; +using RabinChess.Server.API.Stores; namespace RabinChess.Server.API { @@ -16,6 +22,30 @@ public partial class Startup static Startup() { PublicClientId = "self"; + + UserManagerFactory = + () => new UserManager(new UserStore()) {PasswordHasher = new Security.PasswordHasher()}; + + OAuthOptions = new OAuthAuthorizationServerOptions + { + TokenEndpointPath = new PathString("api/token"), + Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory), + AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), + AllowInsecureHttp = true + }; + } + + // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 + public void ConfigureAuth(IAppBuilder app) + { + app.UseCors(CorsOptions.AllowAll); + // Enable the application to use a cookie to store information for the signed in user + // and to use a cookie to temporarily store information about a user logging in with a third party login provider + app.UseCookieAuthentication(new CookieAuthenticationOptions()); + app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); + + // Enable the application to use bearer tokens to authenticate users + app.UseOAuthBearerTokens(OAuthOptions); } } } \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.API/Providers/ApplicationOAuthProvider.cs b/RabinChess.Server/RabinChess.Server.API/Providers/ApplicationOAuthProvider.cs new file mode 100644 index 0000000..ead0888 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.API/Providers/ApplicationOAuthProvider.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNet.Identity; +using Microsoft.Owin.Security; +using Microsoft.Owin.Security.Cookies; +using Microsoft.Owin.Security.OAuth; +using RabinChess.Server.API.Models; + +namespace RabinChess.Server.API.Providers +{ + public class ApplicationOAuthProvider : OAuthAuthorizationServerProvider + { + private readonly string _publicClientId; + private readonly Func> _userManagerFactory; + + public ApplicationOAuthProvider(string publicClientId, Func> userManagerFactory) + { + if (publicClientId == null) + { + throw new ArgumentNullException("publicClientId"); + } + + if (userManagerFactory == null) + { + throw new ArgumentNullException("userManagerFactory"); + } + + _publicClientId = publicClientId; + _userManagerFactory = userManagerFactory; + } + + public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) + { + using (UserManager userManager = _userManagerFactory()) + { + UserModel user = await userManager.FindAsync(context.UserName, context.Password); + + if (user == null) + { + context.SetError("invalid_grant", "The user name or password is incorrect."); + return; + } + + ClaimsIdentity oAuthIdentity = await userManager.CreateIdentityAsync(user, + context.Options.AuthenticationType); + ClaimsIdentity cookiesIdentity = await userManager.CreateIdentityAsync(user, + CookieAuthenticationDefaults.AuthenticationType); + AuthenticationProperties properties = CreateProperties(user.UserName); + AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); + context.Validated(ticket); + context.Request.Context.Authentication.SignIn(cookiesIdentity); + } + } + + public override Task TokenEndpoint(OAuthTokenEndpointContext context) + { + foreach (KeyValuePair property in context.Properties.Dictionary) + { + context.AdditionalResponseParameters.Add(property.Key, property.Value); + } + + return Task.FromResult(null); + } + + public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) + { + // Resource owner password credentials does not provide a client ID. + if (context.ClientId == null) + { + context.Validated(); + } + + return Task.FromResult(null); + } + + public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context) + { + if (context.ClientId == _publicClientId) + { + Uri expectedRootUri = new Uri(context.Request.Uri, "/"); + + if (expectedRootUri.AbsoluteUri == context.RedirectUri) + { + context.Validated(); + } + } + + return Task.FromResult(null); + } + + public static AuthenticationProperties CreateProperties(string userName) + { + IDictionary data = new Dictionary + { + { "userName", userName } + }; + return new AuthenticationProperties(data); + } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj b/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj index 9e37865..7f85f07 100644 --- a/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj +++ b/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj @@ -63,6 +63,10 @@ ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll True + + ..\packages\Microsoft.Owin.Cors.3.0.1\lib\net45\Microsoft.Owin.Cors.dll + True + ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll True @@ -84,6 +88,10 @@ True + + ..\packages\Microsoft.AspNet.Cors.5.0.0\lib\net45\System.Web.Cors.dll + True + @@ -128,6 +136,8 @@ + + diff --git a/RabinChess.Server/RabinChess.Server.API/Security/PasswordHasher.cs b/RabinChess.Server/RabinChess.Server.API/Security/PasswordHasher.cs new file mode 100644 index 0000000..12348f6 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.API/Security/PasswordHasher.cs @@ -0,0 +1,25 @@ +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using Microsoft.AspNet.Identity; + +namespace RabinChess.Server.API.Security +{ + public class PasswordHasher : IPasswordHasher + { + public string HashPassword(string password) + { + var x = new MD5CryptoServiceProvider(); + byte[] passwordBytes = Encoding.ASCII.GetBytes(password); + passwordBytes = x.ComputeHash(passwordBytes); + return passwordBytes.Aggregate("", (current, passwordByte) => current + passwordByte.ToString("x2").ToLower()); + } + + public PasswordVerificationResult VerifyHashedPassword(string hashedPassword, string providedPassword) + { + return hashedPassword == HashPassword(providedPassword) + ? PasswordVerificationResult.Success + : PasswordVerificationResult.Failed; + } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.API/Stores/UserStore.cs b/RabinChess.Server/RabinChess.Server.API/Stores/UserStore.cs index a6bcb76..20740fc 100644 --- a/RabinChess.Server/RabinChess.Server.API/Stores/UserStore.cs +++ b/RabinChess.Server/RabinChess.Server.API/Stores/UserStore.cs @@ -1,6 +1,9 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Microsoft.AspNet.Identity; using RabinChess.Server.API.Models; +using RubinChess.Server.Database.Entities; +using RubinChess.Server.Logic; namespace RabinChess.Server.API.Stores { @@ -13,42 +16,45 @@ public void Dispose() public Task CreateAsync(UserModel user) { - throw new System.NotImplementedException(); + return Task.FromResult(ContextFactory.GetUserContext().AddUser((User) user)); } public Task UpdateAsync(UserModel user) { - throw new System.NotImplementedException(); + return Task.FromResult(ContextFactory.GetUserContext().UpdateUser((User) user)); } public Task DeleteAsync(UserModel user) { - throw new System.NotImplementedException(); + return Task.FromResult(ContextFactory.GetUserContext().DeleteUser(user.Id)); } public Task FindByIdAsync(int userId) { - throw new System.NotImplementedException(); + return Task.FromResult((UserModel) ContextFactory.GetUserContext().GetUser(userId)); } public Task FindByNameAsync(string userName) { - throw new System.NotImplementedException(); + return Task.FromResult((UserModel) ContextFactory.GetUserContext().GetUser(userName)); } public Task SetPasswordHashAsync(UserModel user, string passwordHash) { - throw new System.NotImplementedException(); + user.PasswordHash = passwordHash; + return Task.FromResult(0); } public Task GetPasswordHashAsync(UserModel user) { - throw new System.NotImplementedException(); + if(user == null) + throw new ArgumentNullException("user"); + return Task.FromResult(user.PasswordHash); } public Task HasPasswordAsync(UserModel user) { - throw new System.NotImplementedException(); + return Task.FromResult(user.PasswordHash != null); } } } \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.API/packages.config b/RabinChess.Server/RabinChess.Server.API/packages.config index 8a8f319..667b5d7 100644 --- a/RabinChess.Server/RabinChess.Server.API/packages.config +++ b/RabinChess.Server/RabinChess.Server.API/packages.config @@ -1,14 +1,16 @@  + + - + From 7a17379abad542615a71e9e3e3de7bfd130b32da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Tue, 3 May 2016 21:09:08 +0200 Subject: [PATCH 080/126] Fix --- .../RabinChess.Server.API/App_Start/Startup.Auth.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RabinChess.Server/RabinChess.Server.API/App_Start/Startup.Auth.cs b/RabinChess.Server/RabinChess.Server.API/App_Start/Startup.Auth.cs index 8024718..f6d6849 100644 --- a/RabinChess.Server/RabinChess.Server.API/App_Start/Startup.Auth.cs +++ b/RabinChess.Server/RabinChess.Server.API/App_Start/Startup.Auth.cs @@ -28,7 +28,7 @@ static Startup() OAuthOptions = new OAuthAuthorizationServerOptions { - TokenEndpointPath = new PathString("api/token"), + TokenEndpointPath = new PathString("/api/token"), Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory), AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), AllowInsecureHttp = true From 1d85b06923235079b9ce76df02c400fd2e0741e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Wed, 4 May 2016 15:25:36 +0200 Subject: [PATCH 081/126] fixes --- RabinChess.Web/src/scripts/components/TestPage.jsx | 2 -- .../scripts/components/game_list_layout/GameListLayout.jsx | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/TestPage.jsx b/RabinChess.Web/src/scripts/components/TestPage.jsx index e9d3776..144ab0d 100644 --- a/RabinChess.Web/src/scripts/components/TestPage.jsx +++ b/RabinChess.Web/src/scripts/components/TestPage.jsx @@ -1,7 +1,5 @@ import React from 'react' -import SmartGameList from './game_list' - class TestPage extends React.Component { render(){ return( diff --git a/RabinChess.Web/src/scripts/components/game_list_layout/GameListLayout.jsx b/RabinChess.Web/src/scripts/components/game_list_layout/GameListLayout.jsx index 53b8b07..088d89b 100644 --- a/RabinChess.Web/src/scripts/components/game_list_layout/GameListLayout.jsx +++ b/RabinChess.Web/src/scripts/components/game_list_layout/GameListLayout.jsx @@ -11,13 +11,11 @@ class GameListLayout extends React.Component { return ( - - + - ) From 5e69c6225726470b297d596d14447b8cca998461 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 7 May 2016 19:09:41 +0200 Subject: [PATCH 082/126] Some try with undo --- .../components/chessboard/ChessBoard.jsx | 4 +++ .../components/chessboard/SmartChessBoard.jsx | 33 ++++++++++++++----- .../components/chessboard/chess_board.scss | 2 +- .../chessboard_layout/ChessboardLayout.jsx | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/ChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/ChessBoard.jsx index 84f4569..e8525a7 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/ChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/ChessBoard.jsx @@ -58,6 +58,10 @@ class ChessBoard extends React.Component { }, 0); } + componentWillReceiveProps(nextProps) { + this.board.position(nextProps.fen); + } + _onSnapEnd() { this.props.onSnapEnd(); this.board.position(this.props.fen); diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index 1805f77..6b3455a 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -1,6 +1,6 @@ import React, { PropTypes } from 'react' import ChessJS from 'chess.js' - +import { Button } from 'react-toolbox' import ChessBoard from './ChessBoard' @@ -21,12 +21,23 @@ class SmartChessBoard extends React.Component { let { pgn } = this.props; if (pgn) this.game.load_pgn(pgn.join('\n')); + this.game.undo(); + console.log(this.game.pgn()); this.state = { fen: this.game.fen() }; } + _undo() { + this.game.undo(); + console.log(this.game.ascii()); + console.log(this.game.pgn()); + this.setState({ + fen: this.game.fen() + }); + } + _onDragStart(source, piece, position, orientation) { if (this.game.game_over() === true || (this.game.turn() === 'w' && piece.search(/^b/) !== -1) || @@ -55,15 +66,19 @@ class SmartChessBoard extends React.Component { * @returns {ChessBoard} Chessboard with logic */ render () { + return ( - +
+ + +
) } } diff --git a/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss b/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss index dde16f3..049e5ba 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss +++ b/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss @@ -1,5 +1,5 @@ .chessboard { - width: 500px; + width: 700px; margin-left: auto; margin-right: auto; box-sizing: content-box; diff --git a/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx b/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx index e25e32a..d6e2b8a 100644 --- a/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx @@ -25,7 +25,7 @@ export default class ChessboardLayout extends React.Component { '[WhiteElo "?"]', '[BlackElo "?"]', '[PlyCount "82"]', - `1. d4 Nf6 2. c4 e6 3. Nf3 c5 4. d5 exd5 5. cxd5 d6 6. Nc3 g6 + `1. d4 Nf6 2. c4 e6 ( ... d6 3.c5 ) 3. Nf3 c5 4. d5 exd5 5. cxd5 d6 6. Nc3 g6 7. Nd2 Nbd7 8. e4 Bg7 9. Be2 O-O 10. O-O Re8 11. Qc2 Nh5 12. Bxh5 gxh5 13. Nc4 Ne5 14. Ne3 Qh4 15. Bd2 Ng4 16. Nxg4 hxg4 17. Bf4 Qf6 18. g3 Bd7 19. a4 b6 20. Rfe1 a6 21. Re2 b5 From 1e3383f45ef4f46d18227d612e7b06d29993d450 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 7 May 2016 19:42:13 +0200 Subject: [PATCH 083/126] Add move componentn && fixes --- RabinChess.Web/.vscode/settings.json | 3 ++- .../components/chessboard/SmartChessBoard.jsx | 2 +- .../components/chessboard/components/Move.jsx | 27 +++++++++++++++++++ .../chessboard/components/index.jsx | 3 +++ .../chessboard_layout/ChessboardLayout.jsx | 24 ++++++++--------- 5 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 RabinChess.Web/src/scripts/components/chessboard/components/Move.jsx create mode 100644 RabinChess.Web/src/scripts/components/chessboard/components/index.jsx diff --git a/RabinChess.Web/.vscode/settings.json b/RabinChess.Web/.vscode/settings.json index e6d7e57..42938fc 100644 --- a/RabinChess.Web/.vscode/settings.json +++ b/RabinChess.Web/.vscode/settings.json @@ -1,4 +1,5 @@ // Place your settings in this file to overwrite default and user settings. { - "javascript.validate.enable": false + "javascript.validate.enable": false, + "editor.tabSize": 2 } diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index 6b3455a..0fbcac2 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -20,7 +20,7 @@ class SmartChessBoard extends React.Component { this.game = ChessJS(); let { pgn } = this.props; - if (pgn) this.game.load_pgn(pgn.join('\n')); + if (pgn) this.game.load_pgn(pgn); this.game.undo(); console.log(this.game.pgn()); diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/Move.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/Move.jsx new file mode 100644 index 0000000..daa5cda --- /dev/null +++ b/RabinChess.Web/src/scripts/components/chessboard/components/Move.jsx @@ -0,0 +1,27 @@ +import React, { PropTypes } from 'react' +import { Chip } from 'react-toolbox' + +class Move extends React.Component { + + static PropTypes = { + move: PropTypes.string + } + + constructor(props) { + super(props); + } + + render() { + let { move } = this.props; + + return ( + + + { move } + + + ) + } +} + +export default Move diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx new file mode 100644 index 0000000..fb0a9b7 --- /dev/null +++ b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx @@ -0,0 +1,3 @@ +import Move from './Move' + +export { Move } diff --git a/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx b/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx index d6e2b8a..8a0a2dd 100644 --- a/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx @@ -13,7 +13,7 @@ export default class ChessboardLayout extends React.Component { */ render() { //This is one of my favorites, super cool 11 ...Nh5 - let pgn = ['[Event "Fischer - Spassky World Championship Match"]', + let pgnHeaders = ['[Event "Fischer - Spassky World Championship Match"]', '[Site "Reykjavik ISL"]', '[Date "1972.07.16"]', '[EventDate "?"]', @@ -24,19 +24,19 @@ export default class ChessboardLayout extends React.Component { '[ECO "A61"]', '[WhiteElo "?"]', '[BlackElo "?"]', - '[PlyCount "82"]', - `1. d4 Nf6 2. c4 e6 ( ... d6 3.c5 ) 3. Nf3 c5 4. d5 exd5 5. cxd5 d6 6. Nc3 g6 - 7. Nd2 Nbd7 8. e4 Bg7 9. Be2 O-O 10. O-O Re8 11. Qc2 Nh5 - 12. Bxh5 gxh5 13. Nc4 Ne5 14. Ne3 Qh4 15. Bd2 Ng4 16. Nxg4 - hxg4 17. Bf4 Qf6 18. g3 Bd7 19. a4 b6 20. Rfe1 a6 21. Re2 b5 - 22. Rae1 Qg6 23. b3 Re7 24. Qd3 Rb8 25. axb5 axb5 26. b4 c4 - 27. Qd2 Rbe8 28. Re3 h5 29. R3e2 Kh7 30. Re3 Kg8 31. R3e2 Bxc3 - 32. Qxc3 Rxe4 33. Rxe4 Rxe4 34. Rxe4 Qxe4 35. Bh6 Qg6 36. Bc1 - Qb1 37. Kf1 Bf5 38. Ke2 Qe4+ 39. Qe3 Qc2+ 40. Qd2 Qb3 41. Qd4 - Bd3+ 0-1`]; + '[PlyCount "82"]']; + let pgnGame = `1. d4 Nf6 2. c4 e6 3. Nf3 c5 4. d5 exd5 5. cxd5 d6 6. Nc3 g6 + 7. Nd2 Nbd7 8. e4 Bg7 9. Be2 O-O 10. O-O Re8 11. Qc2 Nh5 + 12. Bxh5 gxh5 13. Nc4 Ne5 14. Ne3 Qh4 15. Bd2 Ng4 16. Nxg4 + hxg4 17. Bf4 Qf6 18. g3 Bd7 19. a4 b6 20. Rfe1 a6 21. Re2 b5 + 22. Rae1 Qg6 23. b3 Re7 24. Qd3 Rb8 25. axb5 axb5 26. b4 c4 + 27. Qd2 Rbe8 28. Re3 h5 29. R3e2 Kh7 30. Re3 Kg8 31. R3e2 Bxc3 + 32. Qxc3 Rxe4 33. Rxe4 Rxe4 34. Rxe4 Qxe4 35. Bh6 Qg6 36. Bc1 + Qb1 37. Kf1 Bf5 38. Ke2 Qe4+ 39. Qe3 Qc2+ 40. Qd2 Qb3 41. Qd4 + Bd3+ 0-1`; return ( - + ) } From 619f8f5e6ed5e583c076c90302167b6b1a6112d8 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 7 May 2016 19:48:37 +0200 Subject: [PATCH 084/126] Add full move component --- .../chessboard/components/FullMove.jsx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 RabinChess.Web/src/scripts/components/chessboard/components/FullMove.jsx diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/FullMove.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/FullMove.jsx new file mode 100644 index 0000000..4b70803 --- /dev/null +++ b/RabinChess.Web/src/scripts/components/chessboard/components/FullMove.jsx @@ -0,0 +1,30 @@ +import React, { PropTypes } from 'react' +import { Chip } from 'react-toolbox' + +import Move from './Move' + +class FullMove extends React.Component { + + static PropTypes = { + moveWhite: PropTypes.string, + moveBlack: PropTypes.string, + number: PropTypes.number + } + + constructor(props) { + super(props); + } + + render() { + let { moveWhite, moveBlack, number } = this.props; + + return ( +
+ + +
+ ) + } +} + +export default FullMove From 4fc11520fc3fe1fbc324f8c463d9c659c306355e Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 7 May 2016 19:51:15 +0200 Subject: [PATCH 085/126] Add move with number comp --- .../components/chessboard/SmartChessBoard.jsx | 2 ++ .../chessboard/components/MoveWithNumber.jsx | 25 +++++++++++++++++++ .../chessboard/components/index.jsx | 4 ++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 RabinChess.Web/src/scripts/components/chessboard/components/MoveWithNumber.jsx diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index 0fbcac2..7e837c1 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -1,7 +1,9 @@ import React, { PropTypes } from 'react' import ChessJS from 'chess.js' import { Button } from 'react-toolbox' + import ChessBoard from './ChessBoard' +import { FullMove } from './components' /** diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/MoveWithNumber.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/MoveWithNumber.jsx new file mode 100644 index 0000000..3b65d33 --- /dev/null +++ b/RabinChess.Web/src/scripts/components/chessboard/components/MoveWithNumber.jsx @@ -0,0 +1,25 @@ +import React, { PropTypes } from 'react' +import { Chip } from 'react-toolbox' + +class MoveWithNumber extends React.Component { + + static PropTypes = { + move: PropTypes.string + } + + constructor(props) { + super(props); + } + + render() { + let { move, number } = this.props; + + return ( + + { move } + + ) + } +} + +export default MoveWithNumber diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx index fb0a9b7..b4e83b3 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx @@ -1,3 +1,5 @@ import Move from './Move' +import FullMove from './FullMove' +import MoveWithNumber from './MoveWithNumber' -export { Move } +export { MoveWithNumber } From eb72e89957c73b54cc5242c12336032f4f6f5930 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 7 May 2016 19:57:05 +0200 Subject: [PATCH 086/126] Fix imports --- .../src/scripts/components/chessboard/SmartChessBoard.jsx | 3 ++- .../src/scripts/components/chessboard/components/FullMove.jsx | 1 + .../components/chessboard/components/MoveWithNumber.jsx | 2 +- .../src/scripts/components/chessboard/components/index.jsx | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index 7e837c1..b9128a8 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -3,7 +3,7 @@ import ChessJS from 'chess.js' import { Button } from 'react-toolbox' import ChessBoard from './ChessBoard' -import { FullMove } from './components' +import FullMove from './components/FullMove.jsx' /** @@ -72,6 +72,7 @@ class SmartChessBoard extends React.Component { return (
+ Date: Sat, 7 May 2016 20:02:04 +0200 Subject: [PATCH 087/126] Add notation comp --- .../chessboard/components/Notation.jsx | 20 +++++++++++++++++++ .../chessboard/components/index.jsx | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx new file mode 100644 index 0000000..715a8dd --- /dev/null +++ b/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx @@ -0,0 +1,20 @@ +import React, { PropTypes } from 'react' +import { Card } from 'react-toolbox' + +class Notation extends React.Component { + + constructor(props) { + super(props); + } + + render() { + + return ( + + { this.props.children } + + ) + } +} + +export default Notation diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx index 65e326d..5a1eed6 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx @@ -1,5 +1,6 @@ import Move from './Move' import FullMove from './FullMove' import MoveWithNumber from './MoveWithNumber' +import Notation from './Notation' -export { MoveWithNumber, FullMove, MoveWithNumber } +export { MoveWithNumber, FullMove, MoveWithNumber, Notation } From d8c1267fcd1785dddf826b5f0a1dcda49bfb218f Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 7 May 2016 20:05:27 +0200 Subject: [PATCH 088/126] Change props --- .../src/scripts/components/chessboard/SmartChessBoard.jsx | 4 ++-- .../scripts/components/chessboard_layout/ChessboardLayout.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index b9128a8..755998c 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -21,8 +21,8 @@ class SmartChessBoard extends React.Component { super(props); this.game = ChessJS(); - let { pgn } = this.props; - if (pgn) this.game.load_pgn(pgn); + let { pgnHeaders, pgnGame } = this.props; + if (pgnGame) this.game.load_pgn( pgnHeaders + pgnGame ); this.game.undo(); console.log(this.game.pgn()); diff --git a/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx b/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx index 8a0a2dd..37d32e5 100644 --- a/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx @@ -36,7 +36,7 @@ export default class ChessboardLayout extends React.Component { Bd3+ 0-1`; return ( - + ) } From c773e792123c32e320b4006148fe1606a0e5dc02 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 7 May 2016 20:09:15 +0200 Subject: [PATCH 089/126] Small fixes --- .../src/scripts/components/chessboard/SmartChessBoard.jsx | 2 +- .../components/chessboard/components/MoveWithNumber.jsx | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index 755998c..c94808e 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -72,7 +72,7 @@ class SmartChessBoard extends React.Component { return (
- + - { move } + + + { move } + ) } From 9ba4f7399b0928e2103647b570484cc28d295de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Mon, 9 May 2016 15:25:55 +0200 Subject: [PATCH 090/126] Get games of current user --- .../RabinChess.Server.API/Controllers/GamesController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RabinChess.Server/RabinChess.Server.API/Controllers/GamesController.cs b/RabinChess.Server/RabinChess.Server.API/Controllers/GamesController.cs index a4cbf7d..84c3452 100644 --- a/RabinChess.Server/RabinChess.Server.API/Controllers/GamesController.cs +++ b/RabinChess.Server/RabinChess.Server.API/Controllers/GamesController.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Web.Http; +using Microsoft.AspNet.Identity; using RabinChess.Server.API.Models; using RubinChess.Server.Logic; @@ -13,7 +14,7 @@ public class GamesController : ApiController [HttpGet] public List Get() { - return ContextFactory.GetGamesContext().GetGames(1).Cast().ToList(); + return ContextFactory.GetGamesContext().GetGames(User.Identity.GetUserId()).Cast().ToList(); } } } From 633b97c19ada3f9bec057a9bed310e22e847b127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Mon, 9 May 2016 15:42:27 +0200 Subject: [PATCH 091/126] Account controller added --- .../Controllers/AccountController.cs | 79 +++++++++++++++++++ .../RabinChess.Server.API.csproj | 1 + .../RabinChess.Server.API/packages.config | 1 + 3 files changed, 81 insertions(+) create mode 100644 RabinChess.Server/RabinChess.Server.API/Controllers/AccountController.cs diff --git a/RabinChess.Server/RabinChess.Server.API/Controllers/AccountController.cs b/RabinChess.Server/RabinChess.Server.API/Controllers/AccountController.cs new file mode 100644 index 0000000..d80e9be --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.API/Controllers/AccountController.cs @@ -0,0 +1,79 @@ +using System.Net.Http; +using System.Web.Http; +using Microsoft.AspNet.Identity; +using Microsoft.Owin.Security; +using Microsoft.Owin.Security.Cookies; +using RabinChess.Server.API.Models; + +namespace RabinChess.Server.API.Controllers +{ + [RoutePrefix("api/Account")] + public class AccountController : ApiController + { + public UserManager UserManager { get; private set; } + public ISecureDataFormat AccessTokenFormat { get; private set; } + + public AccountController() : this(Startup.UserManagerFactory(), Startup.OAuthOptions.AccessTokenFormat) + { + } + + public AccountController(UserManager userManager, + ISecureDataFormat accessTokenFormat) + { + UserManager = userManager; + AccessTokenFormat = accessTokenFormat; + } + + [HttpPost] + [Route("Logout")] + public IHttpActionResult Logout() + { + Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType); + return Ok(); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + UserManager.Dispose(); + } + + base.Dispose(disposing); + } + + private IAuthenticationManager Authentication + { + get { return Request.GetOwinContext().Authentication; } + } + + private IHttpActionResult GetErrorResult(IdentityResult result) + { + if (result == null) + { + return InternalServerError(); + } + + if (!result.Succeeded) + { + if (result.Errors != null) + { + foreach (string error in result.Errors) + { + ModelState.AddModelError("", error); + } + } + + if (ModelState.IsValid) + { + // No ModelState errors are available to send, so just return an empty BadRequest. + return BadRequest(); + } + + return BadRequest(ModelState); + } + + return null; + } + } +} diff --git a/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj b/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj index 7f85f07..ee1bb2f 100644 --- a/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj +++ b/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj @@ -129,6 +129,7 @@ + Global.asax diff --git a/RabinChess.Server/RabinChess.Server.API/packages.config b/RabinChess.Server/RabinChess.Server.API/packages.config index 667b5d7..c37448d 100644 --- a/RabinChess.Server/RabinChess.Server.API/packages.config +++ b/RabinChess.Server/RabinChess.Server.API/packages.config @@ -8,6 +8,7 @@ + From 7a299789ffc244d2e0c643775bb64b3591e51483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Mon, 9 May 2016 15:54:55 +0200 Subject: [PATCH 092/126] csproj --- .../RabinChess.Server.API/RabinChess.Server.API.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj b/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj index ee1bb2f..3807821 100644 --- a/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj +++ b/RabinChess.Server/RabinChess.Server.API/RabinChess.Server.API.csproj @@ -101,6 +101,10 @@ + + ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll + True + From 80970aff888d37c1c11828c2ff4d6467f15dafc6 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Mon, 9 May 2016 20:55:41 +0200 Subject: [PATCH 093/126] Rearrange number of move --- .../chessboard/components/FullMove.jsx | 8 ++++-- .../chessboard/components/NumberOfMove.jsx | 27 +++++++++++++++++++ .../chessboard/components/full_move.scss | 4 +++ .../chessboard/components/index.jsx | 3 ++- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 RabinChess.Web/src/scripts/components/chessboard/components/NumberOfMove.jsx create mode 100644 RabinChess.Web/src/scripts/components/chessboard/components/full_move.scss diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/FullMove.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/FullMove.jsx index a662f04..3ba8ecd 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/FullMove.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/FullMove.jsx @@ -3,6 +3,9 @@ import { Chip } from 'react-toolbox' import Move from './Move' import MoveWithNumber from './MoveWithNumber' +import NumberOfMove from './NumberOfMove' + +import style from './full_move' class FullMove extends React.Component { @@ -20,8 +23,9 @@ class FullMove extends React.Component { let { moveWhite, moveBlack, number } = this.props; return ( -
- +
+ +
) diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/NumberOfMove.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/NumberOfMove.jsx new file mode 100644 index 0000000..ed129dd --- /dev/null +++ b/RabinChess.Web/src/scripts/components/chessboard/components/NumberOfMove.jsx @@ -0,0 +1,27 @@ +import React, { PropTypes } from 'react' +import { Chip } from 'react-toolbox' + +class NumberOfMove extends React.Component { + + static PropTypes = { + number: PropTypes.string + } + + constructor(props) { + super(props); + } + + render() { + let { number } = this.props; + + return ( + + + { number } + + + ) + } +} + +export default NumberOfMove diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/full_move.scss b/RabinChess.Web/src/scripts/components/chessboard/components/full_move.scss new file mode 100644 index 0000000..d795854 --- /dev/null +++ b/RabinChess.Web/src/scripts/components/chessboard/components/full_move.scss @@ -0,0 +1,4 @@ + +.move { + +} \ No newline at end of file diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx index 5a1eed6..6c8e220 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx @@ -2,5 +2,6 @@ import Move from './Move' import FullMove from './FullMove' import MoveWithNumber from './MoveWithNumber' import Notation from './Notation' +import NumberOfMove from './NumberOfMove' -export { MoveWithNumber, FullMove, MoveWithNumber, Notation } +export { MoveWithNumber, FullMove, MoveWithNumber, Notation, NumberOfMove } From 24a570e4eb02907a33b88f965c9efbee8175bb4c Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Mon, 9 May 2016 20:56:37 +0200 Subject: [PATCH 094/126] Some fixes --- .../components/chessboard/SmartChessBoard.jsx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index c94808e..1848f5d 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -23,8 +23,6 @@ class SmartChessBoard extends React.Component { let { pgnHeaders, pgnGame } = this.props; if (pgnGame) this.game.load_pgn( pgnHeaders + pgnGame ); - this.game.undo(); - console.log(this.game.pgn()); this.state = { fen: this.game.fen() @@ -72,15 +70,15 @@ class SmartChessBoard extends React.Component { return (
- - + +
) } From dcc30fc02683c865277a39df8e2244c8ce880a43 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Tue, 10 May 2016 00:37:10 +0200 Subject: [PATCH 095/126] Hohohoe --- .../components/chessboard/SmartChessBoard.jsx | 32 ++++++++++++------- .../chessboard/components/index.jsx | 2 +- .../chessboard_layout/ChessboardLayout.jsx | 10 +----- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index 1848f5d..d6f6c04 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -3,7 +3,7 @@ import ChessJS from 'chess.js' import { Button } from 'react-toolbox' import ChessBoard from './ChessBoard' -import FullMove from './components/FullMove.jsx' +import { FullMove, NumberOfMove, Move, Notation } from './components' /** @@ -61,24 +61,34 @@ class SmartChessBoard extends React.Component { }); } + _renderNotation() { + return this.props.pgnGame.split(' ').map((elem, index) => { + if ( index % 3 === 0) return (); + else return (); + }); + } + /** * Renders wrapped chessboard * @returns {ChessBoard} Chessboard with logic */ render () { - + console.log(this.props.pgnGame); + console.log(this.props.pgnGame.split(' ')); + let moves = this._renderNotation(); + console.log(moves); return (
+ - - + { moves }
) } diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx index 6c8e220..159b310 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/index.jsx @@ -4,4 +4,4 @@ import MoveWithNumber from './MoveWithNumber' import Notation from './Notation' import NumberOfMove from './NumberOfMove' -export { MoveWithNumber, FullMove, MoveWithNumber, Notation, NumberOfMove } +export { FullMove, MoveWithNumber, Notation, NumberOfMove, Move } diff --git a/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx b/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx index 37d32e5..af3e341 100644 --- a/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard_layout/ChessboardLayout.jsx @@ -25,15 +25,7 @@ export default class ChessboardLayout extends React.Component { '[WhiteElo "?"]', '[BlackElo "?"]', '[PlyCount "82"]']; - let pgnGame = `1. d4 Nf6 2. c4 e6 3. Nf3 c5 4. d5 exd5 5. cxd5 d6 6. Nc3 g6 - 7. Nd2 Nbd7 8. e4 Bg7 9. Be2 O-O 10. O-O Re8 11. Qc2 Nh5 - 12. Bxh5 gxh5 13. Nc4 Ne5 14. Ne3 Qh4 15. Bd2 Ng4 16. Nxg4 - hxg4 17. Bf4 Qf6 18. g3 Bd7 19. a4 b6 20. Rfe1 a6 21. Re2 b5 - 22. Rae1 Qg6 23. b3 Re7 24. Qd3 Rb8 25. axb5 axb5 26. b4 c4 - 27. Qd2 Rbe8 28. Re3 h5 29. R3e2 Kh7 30. Re3 Kg8 31. R3e2 Bxc3 - 32. Qxc3 Rxe4 33. Rxe4 Rxe4 34. Rxe4 Qxe4 35. Bh6 Qg6 36. Bc1 - Qb1 37. Kf1 Bf5 38. Ke2 Qe4+ 39. Qe3 Qc2+ 40. Qd2 Qb3 41. Qd4 - Bd3+ 0-1`; + let pgnGame = `1. d4 Nf6 2. c4 e6 3. Nf3 c5 4. d5 exd5 5. cxd5 d6 6. Nc3 g6 7. Nd2 Nbd7 8. e4 Bg7 9. Be2 O-O 10. O-O Re8 11. Qc2 Nh5 12. Bxh5 gxh5 13. Nc4 Ne5 14. Ne3 Qh4 15. Bd2 Ng4 16. Nxg4 hxg4 17. Bf4 Qf6 18. g3 Bd7 19. a4 b6 20. Rfe1 a6 21. Re2 b5 22. Rae1 Qg6 23. b3 Re7 24. Qd3 Rb8 25. axb5 axb5 26. b4 c4 27. Qd2 Rbe8 28. Re3 h5 29. R3e2 Kh7 30. Re3 Kg8 31. R3e2 Bxc3 32. Qxc3 Rxe4 33. Rxe4 Rxe4 34. Rxe4 Qxe4 35. Bh6 Qg6 36. Bc1 Qb1 37. Kf1 Bf5 38. Ke2 Qe4+ 39. Qe3 Qc2+ 40. Qd2 Qb3 41. Qd4 Bd3+ 0-1`; return ( From f8a4a8d5a69f9f38ad2690d6fcb4db5a33806d9a Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Tue, 10 May 2016 00:39:45 +0200 Subject: [PATCH 096/126] Remove console logs --- .../src/scripts/components/chessboard/SmartChessBoard.jsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index d6f6c04..238e867 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -73,10 +73,7 @@ class SmartChessBoard extends React.Component { * @returns {ChessBoard} Chessboard with logic */ render () { - console.log(this.props.pgnGame); - console.log(this.props.pgnGame.split(' ')); let moves = this._renderNotation(); - console.log(moves); return (
Date: Sat, 14 May 2016 17:54:32 +0200 Subject: [PATCH 097/126] Fix layout --- .../src/scripts/components/chessboard/SmartChessBoard.jsx | 2 ++ .../scripts/components/chessboard/components/Notation.jsx | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index 238e867..cecca74 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -85,7 +85,9 @@ class SmartChessBoard extends React.Component { onSnapEnd = { this._onSnapEnd.bind(this) } /> + { moves } +
) } diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx index 715a8dd..b43b55d 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx @@ -1,5 +1,5 @@ import React, { PropTypes } from 'react' -import { Card } from 'react-toolbox' +import { Card, CardText } from 'react-toolbox' class Notation extends React.Component { @@ -8,10 +8,11 @@ class Notation extends React.Component { } render() { - return ( - { this.props.children } + + { this.props.children } + ) } From eab0b9f7d971fbd613942da750224e9d89bac806 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 14 May 2016 18:02:33 +0200 Subject: [PATCH 098/126] Change colors of card --- .../src/scripts/components/chessboard/chess_board.scss | 2 +- .../scripts/components/chessboard/components/Notation.jsx | 4 +++- .../components/chessboard/components/notation_card.scss | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 RabinChess.Web/src/scripts/components/chessboard/components/notation_card.scss diff --git a/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss b/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss index 049e5ba..acf5752 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss +++ b/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss @@ -1,5 +1,5 @@ .chessboard { - width: 700px; + width: 400px; margin-left: auto; margin-right: auto; box-sizing: content-box; diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx index b43b55d..c15e568 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx @@ -1,6 +1,8 @@ import React, { PropTypes } from 'react' import { Card, CardText } from 'react-toolbox' +import style from './notation_card' + class Notation extends React.Component { constructor(props) { @@ -9,7 +11,7 @@ class Notation extends React.Component { render() { return ( - + { this.props.children } diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/notation_card.scss b/RabinChess.Web/src/scripts/components/chessboard/components/notation_card.scss new file mode 100644 index 0000000..0ef8caf --- /dev/null +++ b/RabinChess.Web/src/scripts/components/chessboard/components/notation_card.scss @@ -0,0 +1,6 @@ +@import '../../../../styles/colors'; + + +.notes { + background-color: $crimson-red; +} From fe251471e4cfc8c17d69f0b36dac241eae7a05da Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 14 May 2016 18:05:56 +0200 Subject: [PATCH 099/126] Fix --- .../src/scripts/components/chessboard/chess_board.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss b/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss index acf5752..727346d 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss +++ b/RabinChess.Web/src/scripts/components/chessboard/chess_board.scss @@ -1,5 +1,5 @@ .chessboard { - width: 400px; + width: 550px; margin-left: auto; margin-right: auto; box-sizing: content-box; From 0c13b3408bf81d655f0e74c7d0dbb67762e4e9f7 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sat, 14 May 2016 18:30:55 +0200 Subject: [PATCH 100/126] Turbo design --- .../components/chessboard/SmartChessBoard.jsx | 13 ++++++++++++- .../components/chessboard/components/FullMove.jsx | 3 +++ .../components/chessboard/components/Move.jsx | 2 ++ .../components/chessboard/components/Notation.jsx | 7 ++++++- .../chessboard/components/NumberOfMove.jsx | 4 +++- .../components/chessboard/components/full_move.scss | 11 ++++++++++- 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx index cecca74..050cc2e 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/SmartChessBoard.jsx @@ -68,12 +68,23 @@ class SmartChessBoard extends React.Component { }); } + _renderNotation2() { + let game = this.props.pgnGame.split(' '); + let notes = []; + for (let i=0; i < game.length; i+=3) + { + notes.push(()); + } + return notes; + } + + /** * Renders wrapped chessboard * @returns {ChessBoard} Chessboard with logic */ render () { - let moves = this._renderNotation(); + let moves = this._renderNotation2(); return (
+ ) } } diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/Move.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/Move.jsx index daa5cda..c2e9162 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/Move.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/Move.jsx @@ -1,6 +1,8 @@ import React, { PropTypes } from 'react' import { Chip } from 'react-toolbox' +import style from './full_move' + class Move extends React.Component { static PropTypes = { diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx index c15e568..778f085 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/Notation.jsx @@ -1,5 +1,6 @@ import React, { PropTypes } from 'react' import { Card, CardText } from 'react-toolbox' +import {Grid, Row, Col} from 'react-flexbox-grid' import style from './notation_card' @@ -13,7 +14,11 @@ class Notation extends React.Component { return ( - { this.props.children } + + + { this.props.children } + + ) diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/NumberOfMove.jsx b/RabinChess.Web/src/scripts/components/chessboard/components/NumberOfMove.jsx index ed129dd..d35f2f4 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/NumberOfMove.jsx +++ b/RabinChess.Web/src/scripts/components/chessboard/components/NumberOfMove.jsx @@ -1,6 +1,8 @@ import React, { PropTypes } from 'react' import { Chip } from 'react-toolbox' +import style from './full_move' + class NumberOfMove extends React.Component { static PropTypes = { @@ -15,7 +17,7 @@ class NumberOfMove extends React.Component { let { number } = this.props; return ( - + { number } diff --git a/RabinChess.Web/src/scripts/components/chessboard/components/full_move.scss b/RabinChess.Web/src/scripts/components/chessboard/components/full_move.scss index d795854..b68e1e2 100644 --- a/RabinChess.Web/src/scripts/components/chessboard/components/full_move.scss +++ b/RabinChess.Web/src/scripts/components/chessboard/components/full_move.scss @@ -1,4 +1,13 @@ +@import '../../../../styles/colors'; .move { + //background-color: $snowy-white; + display: inline-block; + margin: 0 5px 0 5px; + padding: 5px 10px 5px 10px; +} -} \ No newline at end of file + +.number { + margin-right: 7px; +} From a8079894dd5ab52a8f4fbc119f65278f7403ca24 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sun, 15 May 2016 23:33:45 +0200 Subject: [PATCH 101/126] Add react thunk --- RabinChess.Web/package.json | 5 +++-- RabinChess.Web/src/scripts/store/configureStore.build.jsx | 3 ++- RabinChess.Web/src/scripts/store/configureStore.dev.jsx | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/RabinChess.Web/package.json b/RabinChess.Web/package.json index 3dd2649..07e3357 100644 --- a/RabinChess.Web/package.json +++ b/RabinChess.Web/package.json @@ -80,8 +80,9 @@ "react-flexbox-grid": "^0.9.6", "react-redux": "^4.4.5", "react-router": "^2.1.1", - "react-toolbox": "^0.16.2", "react-slick": "^0.12.0", - "redux": "^3.5.1" + "react-toolbox": "^0.16.2", + "redux": "^3.5.1", + "redux-thunk": "^2.1.0" } } diff --git a/RabinChess.Web/src/scripts/store/configureStore.build.jsx b/RabinChess.Web/src/scripts/store/configureStore.build.jsx index 9e1bccb..c30497e 100644 --- a/RabinChess.Web/src/scripts/store/configureStore.build.jsx +++ b/RabinChess.Web/src/scripts/store/configureStore.build.jsx @@ -1,4 +1,5 @@ import { createStore, applyMiddleware, compose } from 'redux'; +import thunk from 'redux-thunk'; import reducer from '../reducers'; /** @@ -7,5 +8,5 @@ import reducer from '../reducers'; * @returns Application store */ export default function configureStore(initialState) { - return createStore(reducer, initialState); + return createStore(reducer, applyMiddleware(thunk), initialState); }; diff --git a/RabinChess.Web/src/scripts/store/configureStore.dev.jsx b/RabinChess.Web/src/scripts/store/configureStore.dev.jsx index 32ff93f..fc17444 100644 --- a/RabinChess.Web/src/scripts/store/configureStore.dev.jsx +++ b/RabinChess.Web/src/scripts/store/configureStore.dev.jsx @@ -1,4 +1,5 @@ import { createStore, applyMiddleware, compose } from 'redux'; +import thunk from 'redux-thunk'; import reducer from '../reducers'; import DevTools from '../containers/DevTools'; @@ -12,7 +13,7 @@ const enhancer = compose( * @returns Application store */ export default function configureStore(initialState) { - const store = createStore(reducer, initialState, enhancer); + const store = createStore(reducer, applyMiddleware(thunk), initialState, enhancer); if (module.hot) { module.hot.accept('../reducers', () => From d925dbaf4b1c0541df1e9af80122b7d32b7990df Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Sun, 15 May 2016 23:52:23 +0200 Subject: [PATCH 102/126] Add fetch --- RabinChess.Web/src/scripts/actions/fetch.js | 35 +++++++++++++++++++ .../scripts/actions/{index.jsx => index.js} | 0 .../src/scripts/config/api_config.js | 0 3 files changed, 35 insertions(+) create mode 100644 RabinChess.Web/src/scripts/actions/fetch.js rename RabinChess.Web/src/scripts/actions/{index.jsx => index.js} (100%) create mode 100644 RabinChess.Web/src/scripts/config/api_config.js diff --git a/RabinChess.Web/src/scripts/actions/fetch.js b/RabinChess.Web/src/scripts/actions/fetch.js new file mode 100644 index 0000000..062eecc --- /dev/null +++ b/RabinChess.Web/src/scripts/actions/fetch.js @@ -0,0 +1,35 @@ +import apiConfig from '../api_config'; + +function getInitFetch(method, body, token) { + const headers = new Headers(); + headers.append('Content-Type', 'application/json'); + headers.append('Authorization', `Jabol jaka mamy autoryzacje ${token}`); + + const initFetch = { + method, + headers, + mode: 'cors' + }; + + if (method === 'POST' || method === 'PATCH') { + initFetch.body = body; + } + return initFetch; +} + +export function fetchData(dispatch, url) { + const initFetch = getInitFetch(method, body, token); + let status; + return fetch(apiConfig.url + url, initFetch) + .then(response => { + status = response.status; + return response.json(); + }) + .then(response => { + if (status < 200 || status >= 300) { + console.log(`API ERROR: status ${status}`); + console.log(response); + } + return response; + }) +} diff --git a/RabinChess.Web/src/scripts/actions/index.jsx b/RabinChess.Web/src/scripts/actions/index.js similarity index 100% rename from RabinChess.Web/src/scripts/actions/index.jsx rename to RabinChess.Web/src/scripts/actions/index.js diff --git a/RabinChess.Web/src/scripts/config/api_config.js b/RabinChess.Web/src/scripts/config/api_config.js new file mode 100644 index 0000000..e69de29 From 88e343188e74bfc04b58d71b35c1f3236f521ae5 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Mon, 16 May 2016 00:11:48 +0200 Subject: [PATCH 103/126] Fix footer... --- RabinChess.Web/src/scripts/components/layout/main_layout.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RabinChess.Web/src/scripts/components/layout/main_layout.scss b/RabinChess.Web/src/scripts/components/layout/main_layout.scss index 0892c8f..8d11234 100644 --- a/RabinChess.Web/src/scripts/components/layout/main_layout.scss +++ b/RabinChess.Web/src/scripts/components/layout/main_layout.scss @@ -1,12 +1,12 @@ @import '../../../styles/colors'; .main { - height: 100%; + min-height: 100%; + position:relative; } .header { background-color: $crimson-red; - min-height: 60px; height: 60px; white-space: nowrap; From 4a58ed12e5e8b37d3a4559ea8bd4d981723623f9 Mon Sep 17 00:00:00 2001 From: Marek Rydlewski Date: Mon, 16 May 2016 00:14:07 +0200 Subject: [PATCH 104/126] Fix creating store --- RabinChess.Web/src/scripts/store/configureStore.dev.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RabinChess.Web/src/scripts/store/configureStore.dev.jsx b/RabinChess.Web/src/scripts/store/configureStore.dev.jsx index fc17444..d40b8f9 100644 --- a/RabinChess.Web/src/scripts/store/configureStore.dev.jsx +++ b/RabinChess.Web/src/scripts/store/configureStore.dev.jsx @@ -13,7 +13,7 @@ const enhancer = compose( * @returns Application store */ export default function configureStore(initialState) { - const store = createStore(reducer, applyMiddleware(thunk), initialState, enhancer); + const store = createStore(reducer, initialState, enhancer, applyMiddleware(thunk)); if (module.hot) { module.hot.accept('../reducers', () => From 52a3ec5fcfb4c94b96632659b96d367246816022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Mon, 16 May 2016 22:29:44 +0200 Subject: [PATCH 105/126] Installed packages & sample test --- .../GameListTests.cs | 39 ++++++ .../Properties/AssemblyInfo.cs | 36 ++++++ .../RabinChess.Server.Logic.Test.csproj | 120 ++++++++++++++++++ .../packages.config | 6 + RabinChess.Server/RabinChess.Server.sln | 6 + .../packages/repositories.config | 1 + 6 files changed, 208 insertions(+) create mode 100644 RabinChess.Server/RabinChess.Server.Logic.Test/GameListTests.cs create mode 100644 RabinChess.Server/RabinChess.Server.Logic.Test/Properties/AssemblyInfo.cs create mode 100644 RabinChess.Server/RabinChess.Server.Logic.Test/RabinChess.Server.Logic.Test.csproj create mode 100644 RabinChess.Server/RabinChess.Server.Logic.Test/packages.config diff --git a/RabinChess.Server/RabinChess.Server.Logic.Test/GameListTests.cs b/RabinChess.Server/RabinChess.Server.Logic.Test/GameListTests.cs new file mode 100644 index 0000000..e067925 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic.Test/GameListTests.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using Moq; +using NUnit.Framework; +using RabinChess.Server.DataStructures; +using RubinChess.Server.Logic.Contexts; +using RubinChess.Server.Logic.Interactions; + +namespace RabinChess.Server.Logic.Test +{ + [TestFixture] + public class GameListTests + { + [Test] + public void ListOfGamesIsRetrieved() + { + var mockRetriever = new Mock(); + mockRetriever.Setup(t => t.GetGames(0)) + .Returns(new List + { + new GameListItemVM + { + Id = new Guid("11111111-1111-1111-1111-111111111111"), + Name = "Game 1", + Tags = "Man vs. Woman | Some event" + }, + new GameListItemVM + { + Id = new Guid("22222222-2222-2222-2222-222222222222"), + Name = "Game 2", + Tags = "Someone vs. noone | None event" + } + }); + + IGamesContext context = new GamesContext(mockRetriever.Object); + Assert.AreEqual(context.GetGames(0).Count, 2); + } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic.Test/Properties/AssemblyInfo.cs b/RabinChess.Server/RabinChess.Server.Logic.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2fdbdc7 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("RabinChess.Server.Logic.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RabinChess.Server.Logic.Test")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("284e257e-ed82-43cd-8fac-93719c087fb1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RabinChess.Server/RabinChess.Server.Logic.Test/RabinChess.Server.Logic.Test.csproj b/RabinChess.Server/RabinChess.Server.Logic.Test/RabinChess.Server.Logic.Test.csproj new file mode 100644 index 0000000..d737bd6 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic.Test/RabinChess.Server.Logic.Test.csproj @@ -0,0 +1,120 @@ + + + + Debug + AnyCPU + {4459DFFF-8F2D-44D7-971F-BF35FB82A819} + Library + Properties + RabinChess.Server.Logic.Test + RabinChess.Server.Logic.Test + v4.5 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll + True + + + ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll + False + + + ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll + False + + + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + True + + + ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll + False + + + ..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll + False + + + + + + + + + + + + + + + + + + + + + + + + + {3d934dc5-2d2b-496c-aa69-17bc7a7d07a5} + RabinChess.Server.DataStructures + + + {07351139-6d20-4748-a41d-6b0cfe0086b2} + RabinChess.Server.Logic + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic.Test/packages.config b/RabinChess.Server/RabinChess.Server.Logic.Test/packages.config new file mode 100644 index 0000000..4ef3157 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic.Test/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.sln b/RabinChess.Server/RabinChess.Server.sln index d5205eb..e2f8d3a 100644 --- a/RabinChess.Server/RabinChess.Server.sln +++ b/RabinChess.Server/RabinChess.Server.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabinChess.Server.API", "Ra EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabinChess.Server.DataStructures", "RabinChess.Server.DataStructures\RabinChess.Server.DataStructures.csproj", "{3D934DC5-2D2B-496C-AA69-17BC7A7D07A5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabinChess.Server.Logic.Test", "RabinChess.Server.Logic.Test\RabinChess.Server.Logic.Test.csproj", "{4459DFFF-8F2D-44D7-971F-BF35FB82A819}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {3D934DC5-2D2B-496C-AA69-17BC7A7D07A5}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D934DC5-2D2B-496C-AA69-17BC7A7D07A5}.Release|Any CPU.ActiveCfg = Release|Any CPU {3D934DC5-2D2B-496C-AA69-17BC7A7D07A5}.Release|Any CPU.Build.0 = Release|Any CPU + {4459DFFF-8F2D-44D7-971F-BF35FB82A819}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4459DFFF-8F2D-44D7-971F-BF35FB82A819}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4459DFFF-8F2D-44D7-971F-BF35FB82A819}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4459DFFF-8F2D-44D7-971F-BF35FB82A819}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RabinChess.Server/packages/repositories.config b/RabinChess.Server/packages/repositories.config index ab1e46e..430461b 100644 --- a/RabinChess.Server/packages/repositories.config +++ b/RabinChess.Server/packages/repositories.config @@ -2,5 +2,6 @@ + From 0fdb6fd15bc5087e8ea27e2d6076a1139c4bd53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Tue, 17 May 2016 19:57:48 +0200 Subject: [PATCH 106/126] Fixes and architecture change for easier mocking/testing --- RabinChess.Server/.gitignore | 3 + .../Controllers/GamesController.cs | 2 +- .../RubinChessContext.cs | 6 +- .../RabinChess.Server.Logic/ContextFactory.cs | 8 ++- .../Interactions/GamesRetriever.cs | 14 +++-- .../Interactions/UserManager.cs | 58 ++++++++----------- 6 files changed, 45 insertions(+), 46 deletions(-) diff --git a/RabinChess.Server/.gitignore b/RabinChess.Server/.gitignore index 27d8430..efb6e12 100644 --- a/RabinChess.Server/.gitignore +++ b/RabinChess.Server/.gitignore @@ -213,3 +213,6 @@ ModelManifest.xml # Config files **/connectionStrings.config + +# Publish profiles +RabinChess.Server.API/Properties/PublishProfiles/ diff --git a/RabinChess.Server/RabinChess.Server.API/Controllers/GamesController.cs b/RabinChess.Server/RabinChess.Server.API/Controllers/GamesController.cs index 84c3452..7045dbd 100644 --- a/RabinChess.Server/RabinChess.Server.API/Controllers/GamesController.cs +++ b/RabinChess.Server/RabinChess.Server.API/Controllers/GamesController.cs @@ -14,7 +14,7 @@ public class GamesController : ApiController [HttpGet] public List Get() { - return ContextFactory.GetGamesContext().GetGames(User.Identity.GetUserId()).Cast().ToList(); + return ContextFactory.GetGamesContext().GetGames(User.Identity.GetUserId()).Select(x => (GameListItemViewModel) x).ToList(); } } } diff --git a/RabinChess.Server/RabinChess.Server.Database/RubinChessContext.cs b/RabinChess.Server/RabinChess.Server.Database/RubinChessContext.cs index ef062c2..f53ef47 100644 --- a/RabinChess.Server/RabinChess.Server.Database/RubinChessContext.cs +++ b/RabinChess.Server/RabinChess.Server.Database/RubinChessContext.cs @@ -10,8 +10,8 @@ public RubinChessContext() : base("RubinChess") System.Data.Entity.Database.SetInitializer(new CreateDatabaseIfNotExists()); } - public DbSet Users { get; set; } - public DbSet Games { get; set; } - public DbSet GameTags { get; set; } + public virtual DbSet Users { get; set; } + public virtual DbSet Games { get; set; } + public virtual DbSet GameTags { get; set; } } } \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic/ContextFactory.cs b/RabinChess.Server/RabinChess.Server.Logic/ContextFactory.cs index 16ab248..8f44ce2 100644 --- a/RabinChess.Server/RabinChess.Server.Logic/ContextFactory.cs +++ b/RabinChess.Server/RabinChess.Server.Logic/ContextFactory.cs @@ -1,4 +1,5 @@ -using RubinChess.Server.Logic.Contexts; +using RubinChess.Server.Database; +using RubinChess.Server.Logic.Contexts; using RubinChess.Server.Logic.Interactions; namespace RubinChess.Server.Logic @@ -11,8 +12,9 @@ public static class ContextFactory static ContextFactory() { - GamesContext = new GamesContext(new GamesRetriever()); - UserContext = new UserContext(new UserManager()); + var context = new RubinChessContext(); + GamesContext = new GamesContext(new GamesRetriever(context)); + UserContext = new UserContext(new UserManager(context)); } public static IGamesContext GetGamesContext() diff --git a/RabinChess.Server/RabinChess.Server.Logic/Interactions/GamesRetriever.cs b/RabinChess.Server/RabinChess.Server.Logic/Interactions/GamesRetriever.cs index 2431ce2..441aa7f 100644 --- a/RabinChess.Server/RabinChess.Server.Logic/Interactions/GamesRetriever.cs +++ b/RabinChess.Server/RabinChess.Server.Logic/Interactions/GamesRetriever.cs @@ -8,14 +8,18 @@ namespace RubinChess.Server.Logic.Interactions { public class GamesRetriever : IGamesRetriever { + private RubinChessContext _context; + + public GamesRetriever(RubinChessContext context) + { + _context = context; + } + public List GetGames(int userId) { var gameListItems = new List(); - using (var ctx = new RubinChessContext()) - { - List games = ctx.Users.FirstOrDefault(user => user.Id == userId).Games; - games.ForEach(game => gameListItems.Add(new GameListItemVM{Id = game.Id, Name = game.Name, Tags = TagsStringCreator(game.Tags)})); - } + List games = _context.Users.FirstOrDefault(user => user.Id == userId).Games; + games.ForEach(game => gameListItems.Add(new GameListItemVM{Id = game.Id, Name = game.Name, Tags = TagsStringCreator(game.Tags)})); return gameListItems; } diff --git a/RabinChess.Server/RabinChess.Server.Logic/Interactions/UserManager.cs b/RabinChess.Server/RabinChess.Server.Logic/Interactions/UserManager.cs index 90a335e..ba728b2 100644 --- a/RabinChess.Server/RabinChess.Server.Logic/Interactions/UserManager.cs +++ b/RabinChess.Server/RabinChess.Server.Logic/Interactions/UserManager.cs @@ -7,62 +7,52 @@ namespace RubinChess.Server.Logic.Interactions { public class UserManager : IUserManager { + private RubinChessContext _context; + + public UserManager(RubinChessContext context) + { + _context = context; + } + public int AddUser(User user) { - int newUserId; - using (var ctx = new RubinChessContext()) - { - User newUser = ctx.Users.Add(user); - ctx.SaveChanges(); - newUserId = newUser.Id; - } + User newUser = _context.Users.Add(user); + _context.SaveChanges(); + int newUserId = newUser.Id; + return newUserId; } public bool DeleteUser(int userId) { - using (var ctx = new RubinChessContext()) - { - ctx.Users.Remove(ctx.Users.FirstOrDefault(user => user.Id == userId)); - ctx.SaveChanges(); - } + _context.Users.Remove(_context.Users.FirstOrDefault(user => user.Id == userId)); + _context.SaveChanges(); + return true; } public int UpdateUser(User user) { - int userId; - using (var ctx = new RubinChessContext()) - { - var existingUser = ctx.Users.FirstOrDefault(dbUser => dbUser.Id == user.Id); - existingUser.Email = user.Email; - existingUser.FirstName = user.FirstName; - existingUser.LastName = user.LastName; - existingUser.PasswordHash = user.PasswordHash; - existingUser.UserName = user.UserName; - ctx.SaveChanges(); - userId = existingUser.Id; - } + var existingUser = _context.Users.FirstOrDefault(dbUser => dbUser.Id == user.Id); + existingUser.Email = user.Email; + existingUser.FirstName = user.FirstName; + existingUser.LastName = user.LastName; + existingUser.PasswordHash = user.PasswordHash; + existingUser.UserName = user.UserName; + _context.SaveChanges(); + int userId = existingUser.Id; return userId; } public User GetUser(int userId) { - User user; - using (var ctx = new RubinChessContext()) - { - user = ctx.Users.Include(dbUser => dbUser.Games).FirstOrDefault(dbUser => dbUser.Id == userId); - } + User user = _context.Users.Include(dbUser => dbUser.Games).FirstOrDefault(dbUser => dbUser.Id == userId); return user; } public User GetUser(string userName) { - User user; - using (var ctx = new RubinChessContext()) - { - user = ctx.Users.Include(dbUser => dbUser.Games).FirstOrDefault(dbUser => dbUser.UserName == userName); - } + User user = _context.Users.Include(dbUser => dbUser.Games).FirstOrDefault(dbUser => dbUser.UserName == userName); return user; } } From 9ae234dafa0e6dbd82b156e062d4b3a16a1727cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Tue, 17 May 2016 20:36:13 +0200 Subject: [PATCH 107/126] Better sample test --- .../RabinChess.Server.Logic.Test/App.config | 17 +++ .../GameListTests.cs | 35 +++--- .../RabinChess.Server.Logic.Test.csproj | 15 +++ .../TestDataFactory.cs | 110 ++++++++++++++++++ .../packages.config | 1 + 5 files changed, 159 insertions(+), 19 deletions(-) create mode 100644 RabinChess.Server/RabinChess.Server.Logic.Test/App.config create mode 100644 RabinChess.Server/RabinChess.Server.Logic.Test/TestDataFactory.cs diff --git a/RabinChess.Server/RabinChess.Server.Logic.Test/App.config b/RabinChess.Server/RabinChess.Server.Logic.Test/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic.Test/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic.Test/GameListTests.cs b/RabinChess.Server/RabinChess.Server.Logic.Test/GameListTests.cs index e067925..8a1d70e 100644 --- a/RabinChess.Server/RabinChess.Server.Logic.Test/GameListTests.cs +++ b/RabinChess.Server/RabinChess.Server.Logic.Test/GameListTests.cs @@ -1,8 +1,12 @@ using System; using System.Collections.Generic; +using System.Data.Entity; +using System.Linq; using Moq; using NUnit.Framework; using RabinChess.Server.DataStructures; +using RubinChess.Server.Database; +using RubinChess.Server.Database.Entities; using RubinChess.Server.Logic.Contexts; using RubinChess.Server.Logic.Interactions; @@ -14,26 +18,19 @@ public class GameListTests [Test] public void ListOfGamesIsRetrieved() { - var mockRetriever = new Mock(); - mockRetriever.Setup(t => t.GetGames(0)) - .Returns(new List - { - new GameListItemVM - { - Id = new Guid("11111111-1111-1111-1111-111111111111"), - Name = "Game 1", - Tags = "Man vs. Woman | Some event" - }, - new GameListItemVM - { - Id = new Guid("22222222-2222-2222-2222-222222222222"), - Name = "Game 2", - Tags = "Someone vs. noone | None event" - } - }); + var mockGamesSet = TestDataFactory.GetSampleGames(); - IGamesContext context = new GamesContext(mockRetriever.Object); - Assert.AreEqual(context.GetGames(0).Count, 2); + var mockDbContext = new Mock(); + mockDbContext.Setup(m => m.Games).Returns(mockGamesSet.Object); + + var gamesRetriever = new GamesRetriever(mockDbContext.Object); + var games = gamesRetriever.GetGames(1); + + Assert.AreEqual(2, games.Count); + Assert.Contains("Test1", games.Select(g => g.Name).ToList()); + Assert.Contains("Test2", games.Select(g => g.Name).ToList()); + Assert.Contains("Tag1 vs. Tag2 | Tag3", games.Select(g => g.Tags).ToList()); + Assert.Contains("Tag4 vs. Tag5 | Tag6", games.Select(g => g.Tags).ToList()); } } } \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic.Test/RabinChess.Server.Logic.Test.csproj b/RabinChess.Server/RabinChess.Server.Logic.Test/RabinChess.Server.Logic.Test.csproj index d737bd6..7dbccdb 100644 --- a/RabinChess.Server/RabinChess.Server.Logic.Test/RabinChess.Server.Logic.Test.csproj +++ b/RabinChess.Server/RabinChess.Server.Logic.Test/RabinChess.Server.Logic.Test.csproj @@ -35,6 +35,14 @@ 4 + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + True + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + True + ..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll True @@ -60,6 +68,7 @@ False + @@ -76,11 +85,17 @@ + + + + {28073fba-2df2-4df6-a519-e4ddff3cded9} + RabinChess.Server.Database + {3d934dc5-2d2b-496c-aa69-17bc7a7d07a5} RabinChess.Server.DataStructures diff --git a/RabinChess.Server/RabinChess.Server.Logic.Test/TestDataFactory.cs b/RabinChess.Server/RabinChess.Server.Logic.Test/TestDataFactory.cs new file mode 100644 index 0000000..a2d2596 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Logic.Test/TestDataFactory.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Data.Entity; +using System.Linq; +using Moq; +using RubinChess.Server.Database.Entities; + +namespace RabinChess.Server.Logic.Test +{ + public static class TestDataFactory + { + public static Mock> GetSampleGames() + { + var games = new List + { + new Game + { + Id = new Guid("11111111-1111-1111-1111-111111111111"), + Name = "Test1", + Tags = + new List + { + new GameTag + { + GameId = new Guid("11111111-1111-1111-1111-111111111111"), + Name = "White", + Value = "Tag1" + }, + new GameTag + { + GameId = new Guid("11111111-1111-1111-1111-111111111111"), + Name = "Black", + Value = "Tag2" + }, + new GameTag + { + GameId = new Guid("11111111-1111-1111-1111-111111111111"), + Name = "Event", + Value = "Tag3" + } + }, + GameNotation = "", + UserId = 1 + }, + new Game + { + Id = new Guid("22222222-2222-2222-2222-222222222222"), + Name = "Test2", + Tags = + new List + { + new GameTag + { + GameId = new Guid("22222222-2222-2222-2222-222222222222"), + Name = "White", + Value = "Tag4" + }, + new GameTag + { + GameId = new Guid("22222222-2222-2222-2222-222222222222"), + Name = "Black", + Value = "Tag5" + }, + new GameTag + { + GameId = new Guid("22222222-2222-2222-2222-222222222222"), + Name = "Event", + Value = "Tag6" + } + }, + GameNotation = "", + UserId = 1 + } + }.AsQueryable(); + + var mockGamesSet = new Mock>(); + mockGamesSet.As>().Setup(m => m.Provider).Returns(games.Provider); + mockGamesSet.As>().Setup(m => m.Expression).Returns(games.Expression); + mockGamesSet.As>().Setup(m => m.ElementType).Returns(games.ElementType); + mockGamesSet.As>().Setup(m => m.GetEnumerator()).Returns(() => games.GetEnumerator()); + + return mockGamesSet; + } + + public static Mock> GetSampleUsers() + { + var users = new List + { + new User + { + Email = "", + FirstName = "", + Games = new List(), + Id = 1, + LastName = "", + PasswordHash = "", + UserName = "user" + } + }.AsQueryable(); + + var mockUserSet = new Mock>(); + mockUserSet.As>().Setup(m => m.Provider).Returns(users.Provider); + mockUserSet.As>().Setup(m => m.Expression).Returns(users.Expression); + mockUserSet.As>().Setup(m => m.ElementType).Returns(users.ElementType); + mockUserSet.As>().Setup(m => m.GetEnumerator()).Returns(() => users.GetEnumerator()); + + return mockUserSet; + } + } +} \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Logic.Test/packages.config b/RabinChess.Server/RabinChess.Server.Logic.Test/packages.config index 4ef3157..a40006f 100644 --- a/RabinChess.Server/RabinChess.Server.Logic.Test/packages.config +++ b/RabinChess.Server/RabinChess.Server.Logic.Test/packages.config @@ -1,5 +1,6 @@  + From b4a1ad17f72109159a73ff232019ec286243643f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Tue, 17 May 2016 20:37:51 +0200 Subject: [PATCH 108/126] Hotfix1 --- .../RabinChess.Server.Logic/Interactions/GamesRetriever.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RabinChess.Server/RabinChess.Server.Logic/Interactions/GamesRetriever.cs b/RabinChess.Server/RabinChess.Server.Logic/Interactions/GamesRetriever.cs index 441aa7f..dd9aa58 100644 --- a/RabinChess.Server/RabinChess.Server.Logic/Interactions/GamesRetriever.cs +++ b/RabinChess.Server/RabinChess.Server.Logic/Interactions/GamesRetriever.cs @@ -18,7 +18,7 @@ public GamesRetriever(RubinChessContext context) public List GetGames(int userId) { var gameListItems = new List(); - List games = _context.Users.FirstOrDefault(user => user.Id == userId).Games; + List games = _context.Games.Where(g => g.UserId == userId).ToList(); games.ForEach(game => gameListItems.Add(new GameListItemVM{Id = game.Id, Name = game.Name, Tags = TagsStringCreator(game.Tags)})); return gameListItems; } From 64f1ac5ddd6f917c3d34da12b38b87d6f6f8d9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Jab=C5=82o=C5=84ski?= Date: Tue, 17 May 2016 21:02:26 +0200 Subject: [PATCH 109/126] added migrations, not working user add ? --- .../Entities/User.cs | 2 + .../201605031506553_InitialCreate.Designer.cs | 29 ++++ .../201605031506553_InitialCreate.cs | 61 +++++++++ .../201605031506553_InitialCreate.resx | 126 ++++++++++++++++++ ...05171858497_UserIdAutoGenerate.Designer.cs | 29 ++++ .../201605171858497_UserIdAutoGenerate.cs | 16 +++ .../201605171858497_UserIdAutoGenerate.resx | 126 ++++++++++++++++++ .../Migrations/Configuration.cs | 32 +++++ .../RabinChess.Server.Database.csproj | 17 +++ .../GameListTests.cs | 10 +- .../RabinChess.Server.Logic.Test.csproj | 1 + .../TestDataFactory.cs | 16 ++- .../UserManagerTests.cs | 31 +++++ 13 files changed, 486 insertions(+), 10 deletions(-) create mode 100644 RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.Designer.cs create mode 100644 RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.cs create mode 100644 RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.resx create mode 100644 RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.Designer.cs create mode 100644 RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.cs create mode 100644 RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.resx create mode 100644 RabinChess.Server/RabinChess.Server.Database/Migrations/Configuration.cs create mode 100644 RabinChess.Server/RabinChess.Server.Logic.Test/UserManagerTests.cs diff --git a/RabinChess.Server/RabinChess.Server.Database/Entities/User.cs b/RabinChess.Server/RabinChess.Server.Database/Entities/User.cs index 72eca97..f8f6b53 100644 --- a/RabinChess.Server/RabinChess.Server.Database/Entities/User.cs +++ b/RabinChess.Server/RabinChess.Server.Database/Entities/User.cs @@ -1,11 +1,13 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace RubinChess.Server.Database.Entities { public class User { [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [MinLength(5), MaxLength(25), Required] diff --git a/RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.Designer.cs b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.Designer.cs new file mode 100644 index 0000000..c5c28d9 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.Designer.cs @@ -0,0 +1,29 @@ +// +namespace RubinChess.Server.Database.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")] + public sealed partial class InitialCreate : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(InitialCreate)); + + string IMigrationMetadata.Id + { + get { return "201605031506553_InitialCreate"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.cs b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.cs new file mode 100644 index 0000000..86b574f --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.cs @@ -0,0 +1,61 @@ +namespace RubinChess.Server.Database.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class InitialCreate : DbMigration + { + public override void Up() + { + CreateTable( + "dbo.Games", + c => new + { + Id = c.Guid(nullable: false), + UserId = c.Int(nullable: false), + GameNotation = c.String(nullable: false), + Name = c.String(), + }) + .PrimaryKey(t => t.Id) + .ForeignKey("dbo.Users", t => t.UserId, cascadeDelete: true) + .Index(t => t.UserId); + + CreateTable( + "dbo.GameTags", + c => new + { + GameId = c.Guid(nullable: false), + Name = c.String(nullable: false, maxLength: 128), + Value = c.String(nullable: false), + }) + .PrimaryKey(t => new { t.GameId, t.Name }) + .ForeignKey("dbo.Games", t => t.GameId, cascadeDelete: true) + .Index(t => t.GameId); + + CreateTable( + "dbo.Users", + c => new + { + Id = c.Int(nullable: false, identity: true), + UserName = c.String(nullable: false, maxLength: 25), + PasswordHash = c.String(nullable: false), + Email = c.String(nullable: false), + FirstName = c.String(nullable: false, maxLength: 25), + LastName = c.String(nullable: false, maxLength: 40), + }) + .PrimaryKey(t => t.Id); + + } + + public override void Down() + { + DropForeignKey("dbo.Games", "UserId", "dbo.Users"); + DropForeignKey("dbo.GameTags", "GameId", "dbo.Games"); + DropIndex("dbo.GameTags", new[] { "GameId" }); + DropIndex("dbo.Games", new[] { "UserId" }); + DropTable("dbo.Users"); + DropTable("dbo.GameTags"); + DropTable("dbo.Games"); + } + } +} diff --git a/RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.resx b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.resx new file mode 100644 index 0000000..d2e4df2 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605031506553_InitialCreate.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 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 + + + dbo + + \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.Designer.cs b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.Designer.cs new file mode 100644 index 0000000..d8479af --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.Designer.cs @@ -0,0 +1,29 @@ +// +namespace RubinChess.Server.Database.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")] + public sealed partial class UserIdAutoGenerate : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(UserIdAutoGenerate)); + + string IMigrationMetadata.Id + { + get { return "201605171858497_UserIdAutoGenerate"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.cs b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.cs new file mode 100644 index 0000000..60525f6 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.cs @@ -0,0 +1,16 @@ +namespace RubinChess.Server.Database.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class UserIdAutoGenerate : DbMigration + { + public override void Up() + { + } + + public override void Down() + { + } + } +} diff --git a/RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.resx b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.resx new file mode 100644 index 0000000..d2e4df2 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Migrations/201605171858497_UserIdAutoGenerate.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 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 + + + dbo + + \ No newline at end of file diff --git a/RabinChess.Server/RabinChess.Server.Database/Migrations/Configuration.cs b/RabinChess.Server/RabinChess.Server.Database/Migrations/Configuration.cs new file mode 100644 index 0000000..f2dd0e1 --- /dev/null +++ b/RabinChess.Server/RabinChess.Server.Database/Migrations/Configuration.cs @@ -0,0 +1,32 @@ +namespace RubinChess.Server.Database.Migrations +{ + using System; + using System.Data.Entity; + using System.Data.Entity.Migrations; + using System.Linq; + + internal sealed class Configuration : DbMigrationsConfiguration + { + public Configuration() + { + AutomaticMigrationsEnabled = false; + ContextKey = "RubinChess.Server.Database.RubinChessContext"; + } + + protected override void Seed(RubinChess.Server.Database.RubinChessContext context) + { + // This method will be called after migrating to the latest version. + + // You can use the DbSet.AddOrUpdate() helper extension method + // to avoid creating duplicate seed data. E.g. + // + // context.People.AddOrUpdate( + // p => p.FullName, + // new Person { FullName = "Andrew Peters" }, + // new Person { FullName = "Brice Lambson" }, + // new Person { FullName = "Rowan Miller" } + // ); + // + } + } +} diff --git a/RabinChess.Server/RabinChess.Server.Database/RabinChess.Server.Database.csproj b/RabinChess.Server/RabinChess.Server.Database/RabinChess.Server.Database.csproj index dd9d8c3..267d09f 100644 --- a/RabinChess.Server/RabinChess.Server.Database/RabinChess.Server.Database.csproj +++ b/RabinChess.Server/RabinChess.Server.Database/RabinChess.Server.Database.csproj @@ -51,6 +51,15 @@ + + + 201605031506553_InitialCreate.cs + + + + 201605171858497_UserIdAutoGenerate.cs + + @@ -62,6 +71,14 @@ + + + 201605031506553_InitialCreate.cs + + + 201605171858497_UserIdAutoGenerate.cs + +