Exemplo n.º 1
0
        public void DeletePlayer(DbPlayer deletedPlayer)
        {
            var existingPlayer = _context.Players.FirstOrDefault(p => p.PlayerId == deletedPlayer.PlayerId);
            existingPlayer.IsDeleted = true;
            SetDateAndUserUpdatedInfo(existingPlayer);

            _context.Players.AddOrUpdate(existingPlayer);
            _context.SaveChanges();
        }
Exemplo n.º 2
0
        public void UpdatePlayer(DbPlayer updatedPlayer)
        {
            SetDateAndUserUpdatedInfo(updatedPlayer);
            var existingPlayer = _context.Players.FirstOrDefault(p => p.PlayerId == updatedPlayer.PlayerId);
            existingPlayer.MapFrom(updatedPlayer);

            _context.Players.AddOrUpdate(existingPlayer);
            _context.SaveChanges();
        }
Exemplo n.º 3
0
 private void SetDateAndUserUpdatedInfo(DbPlayer player)
 {
     player.LastModified = DateTime.UtcNow;
     player.LastModifiedBy = "System Admin";
 }
Exemplo n.º 4
0
 private void SetDateAndUserCreatedInfo(DbPlayer player)
 {
     player.Created = DateTime.UtcNow;
     player.CreatedBy = "System Admin";
 }
Exemplo n.º 5
0
 public void CreatePlayer(DbPlayer player)
 {
     SetDateAndUserCreatedInfo(player);
     _context.Players.Add(player);
     _context.SaveChanges();
 }