Exemplo n.º 1
0
 /// <summary>
 /// Mapping method from view model to entity model.
 /// </summary>
 /// <param name="match">Object that will be mapped.</param>
 /// <returns>New mapped object.</returns>
 public static Match MapToMatch(MatchViewModel match)
 {
     return(new Match
     {
         ID = match.ID,
         DateCreated = match.DatePlayed,
         Description = MatchService.GetDescription(match.WhiteName, match.BlackName, match.Result, match.Place, match.DatePlayed.ToShortDateString()),
         Result = match.Result,
         Moves = MoveParser.ParseMatchMoves(match.Moves, "")
     });
 }
Exemplo n.º 2
0
        public void Match(int whiteId, int blackId, string result, string pieces, string moves, bool isRated)
        {
            var white = userRepository.FindUserById(whiteId);
            var black = userRepository.FindUserById(blackId);
            var match = new Match
            {
                White       = white,
                Black       = black,
                Comments    = new List <Comment>(),
                Moves       = MoveParser.ParseMatchMoves(moves, pieces),
                DateCreated = DateTime.Now,
                Result      = result,
                IsPlayed    = true,
                IsRated     = isRated,
                Description = MatchService.GetDescription(white.UserName, black.UserName, result, "ChessMasters.com", DateTime.Now.ToShortDateString())
            };

            matchRepository.SaveMatch(match);
            CalculateRating(result, white, black);
        }