public IHttpActionResult Post(PlayerPostDto dto)
        {
            var result = _playerRepository.CreatePlayer(dto);

            if (result == null)
            {
                return(BadRequest());
            }
            return(Ok(result));
        }
        public async Task <IActionResult> Create([Bind("PlayerID,Name")] Player player)
        {
            if (ModelState.IsValid)
            {
                await _playerRepository.CreatePlayer(player);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(player));
        }
Exemplo n.º 3
0
        private void SetPreTestAction(ITestRunner testRunner)
        {
            testRunner.PreTest = (context) =>
            {
                ISenseiAttribute sensei = attributeUtility.GetAttribute <SenseiAttribute>(context.ClassUnderTest);
                IBattleAttribute battle = attributeUtility.GetAttribute <BattleAttribute>(context.ClassUnderTest);
                battle.Sensei = sensei;
                playerRepository.CreatePlayer(sensei.Name);

                battleRepository.CreateBattle(battle, sensei);
            };
        }
Exemplo n.º 4
0
        public void CreatePlayer(L2Player player)
        {
            // TODO Use automapper to map this
            var playerContract = new PlayerContract
            {
                AccountName    = player.AccountName,
                ObjectId       = player.ObjId,
                Name           = player.Name,
                Level          = player.Level,
                MaxHp          = player.MaxHp,
                CurHp          = (int)player.CharStatus.CurrentHp,
                MaxCp          = player.MaxCp,
                CurCp          = (int)player.CurCp,
                MaxMp          = player.MaxMp,
                CurMp          = (int)player.CharStatus.CurrentMp,
                Face           = (int)player.Face,
                HairStyle      = (int)player.HairStyleId,
                HairColor      = (int)player.HairColor,
                Sex            = (int)player.Sex,
                Heading        = player.Heading,
                X              = player.X,
                Y              = player.Y,
                Z              = player.Z,
                Exp            = player.Exp,
                ExpBeforeDeath = player.ExpOnDeath,
                Sp             = player.Sp,
                Karma          = player.Karma,
                PvpKills       = player.PvpKills,
                PkKills        = player.PkKills,
                Race           = (int)player.BaseClass.ClassId.ClassRace,
                ClassId        = (int)player.ActiveClass.ClassId.Id,
                BaseClass      = (int)player.BaseClass.ClassId.Id,
                DeleteTime     = player.DeleteTime,
                CanCraft       = player.CanCraft,
                Title          = player.Title,
                RecHave        = player.RecHave,
                RecLeft        = player.RecLeft,
                AccessLevel    = player.AccessLevel,
                Online         = player.Online,
                OnlineTime     = player.OnlineTime,
                CharSlot       = player.CharSlot,
                LastAccess     = player.LastAccess,
                PunishLevel    = player.PunishLevel,
                PunishTimer    = player.PunishTimer,
                PowerGrade     = player.PowerGrade,
                Nobless        = player.Nobless,
                Hero           = player.Hero,
                LastRecomDate  = player.LastRecomDate
            };

            _playerRepository.CreatePlayer(playerContract);
        }
Exemplo n.º 5
0
        public bool TryAddPlayer(string name, out IPlayer added)
        {
            added = null;
            if (!IsNameUsed(name))
            {
                added = playerRepository.CreatePlayer(name);
                if (added != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        public ActionResult Create(Player player)
        {
            try
            {
                if (Session["UserAccountID"] == null)
                {
                    return(RedirectToAction("Validate", "Login"));
                }
                User user = (User)Session["User"];
                ViewData["LoginInfo"] = Utility.BuildUserAccountString(user.Username, Convert.ToString(Session["UserAccountName"]));
                if (user.IsAdmin)
                {
                    ViewData["txtIsAdmin"] = "true";
                }
                else
                {
                    ViewData["txtIsAdmin"] = "false";
                }

                if (ModelState.IsValid)
                {
                    // Set NULLs to Empty Strings
                    player               = FillNulls(player);
                    player.AccountID     = Convert.ToInt32(Session["UserAccountID"]);
                    player.PlayerGroupID = Convert.ToInt32(Request.Form["lstPlayerGroup"]);

                    string validation = ValidateInput(player);
                    if (!String.IsNullOrEmpty(validation))
                    {
                        ViewData["ValidationMessage"] = validation;
                        ViewData["PlayerGroupList"]   = new SelectList(BuildPlayerGroupList(false), "Value", "Text", player.PlayerGroupID);
                        return(View(player));
                    }

                    repository.CreatePlayer(player);

                    CommonMethods.CreateActivityLog((User)Session["User"], "Player", "Add",
                                                    "Added player '" + player.PlayerName + "' - ID: " + player.PlayerID.ToString());

                    return(RedirectToAction("Index"));
                }

                return(View(player));
            }
            catch (Exception ex)
            {
                Helpers.SetupApplicationError("Player", "Create POST", ex.Message);
                return(RedirectToAction("Index", "ApplicationError"));
            }
        }
Exemplo n.º 7
0
        public async Task <Player> CreatePlayer(string name, string email)
        {
            var dbPlayer = await _playerRepository.GetPlayer(email);

            if (dbPlayer != null)
            {
                throw new PlayerAlreadyExistsException();
            }

            var player = new Player
            {
                Name  = name,
                Email = email
            };

            return(await _playerRepository.CreatePlayer(player));
        }
Exemplo n.º 8
0
        public CreatePlayerResponse CreatePlayer(CreatePlayerRequest request)
        {
            if (request == null)
            {
                AddNotification("CreatePlayerRequest", Message.X0_IS_REQUIRED.ToFormat("CreatePlayerRequest"));
            }

            var email  = new Email(request.Email);
            var name   = new Name(request.FirstName, request.LastName);
            var player = new Player(name, email, request.Password);

            AddNotifications(player);

            if (IsInvalid())
            {
                return(null);
            }

            return((CreatePlayerResponse)_playerRepository.CreatePlayer(player));
        }
Exemplo n.º 9
0
        public async Task <Result> RegisterUser(UserRegisterModel model)
        {
            var user = _mapper.Map <UserRegisterModel, User>(model);

            user.RegistrationDate = DateTime.Now;
            var identityResult = await _userManager.CreateAsync(user, model.Password);

            var result = identityResult.ToResult();

            if (result.IsSucessfull)
            {
                Player player = new Player()
                {
                    UserId = user.Id, UserName = user.UserName
                };
                _playerRepository.CreatePlayer(player);
                await _playerRepository.SaveAsync();

                var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                result.Values = new object[] { new { userId = user.Id, token } };
            }
            return(result);
        }
Exemplo n.º 10
0
        // POST: api/Players
        //[HttpPost]
        //public void Post([FromBody] string value)
        //{

        //    var pl = new PlayerWrap()
        //    {
        //        Name = "12",
        //        Opponent = "2",
        //        GameResult = GameResult.DRAW,
        //        TotalMoves = 2,
        //        ConnectionId = "2114124",
        //        TotalScore = 1254,
        //        GameFinish = new DateTime(),
        //        GameStart = new DateTime(),
        //        GameType = GameTypes.OsemXOsem,
        //        Points = 2
        //    };
        //    _playerRepository.CreatePlayer(pl);
        //}

        //[HttpPost]
        public void Post([FromBody] PlayerWrap value)
        {
            _playerRepository.CreatePlayer(value);
        }
Exemplo n.º 11
0
 public Player CreatePlayer(Player thisPlayer)
 {
     return(_playerRepository.CreatePlayer(thisPlayer));
 }
Exemplo n.º 12
0
 public IActionResult CreatePlayer(Player player)
 {
     return(Ok(_playerRepository.CreatePlayer(player)));
 }
Exemplo n.º 13
0
 public IActionResult CreatePlayer(Player player, string characterName)
 {
     return(CreatedAtAction(nameof(CreatePlayer), _playerRepository.CreatePlayer(player, characterName)));
 }
Exemplo n.º 14
0
        public async static Task SeedUsers(UserManager <User> userManager, IPlayerRepository playerRepository)
        {
            var username = await userManager.FindByNameAsync("popay");

            if (username == null)
            {
                User user = new User
                {
                    UserName         = "******",
                    Email            = "*****@*****.**",
                    Gender           = Gender.Male,
                    RegistrationDate = DateTime.Now,
                    EmailConfirmed   = true
                };

                var result = await userManager.CreateAsync(user, "asdasd");

                if (result.Succeeded)
                {
                    Player player = new Player
                    {
                        UserId   = user.Id,
                        UserName = user.UserName
                    };
                    playerRepository.CreatePlayer(player);
                    playerRepository.Save();
                }
            }

            //username = await userManager.FindByNameAsync("daf");
            //if (username == null)
            //{
            //    User user = new User
            //    {
            //        UserName = "******",
            //        Email = "*****@*****.**",
            //        Gender = Gender.Male,
            //        RegistrationDate = DateTime.Now,
            //        EmailConfirmed = true
            //    };

            //    var result = await userManager.CreateAsync(user, "asdasd");
            //    if (result.Succeeded)
            //    {
            //        Player player = new Player
            //        {
            //            UserId = user.Id,
            //            UserName = user.UserName
            //        };
            //        playerRepository.CreatePlayer(player);
            //        playerRepository.Save();
            //    }
            //}

            //username = await userManager.FindByNameAsync("miki");
            //if (username == null)
            //{
            //    User user = new User
            //    {
            //        UserName = "******",
            //        Email = "*****@*****.**",
            //        Gender = Gender.Male,
            //        RegistrationDate = DateTime.Now,
            //        EmailConfirmed = true
            //    };

            //    var result = await userManager.CreateAsync(user, "asdasd");
            //    if (result.Succeeded)
            //    {
            //        Player player = new Player
            //        {
            //            UserId = user.Id,
            //            UserName = user.UserName
            //        };
            //        playerRepository.CreatePlayer(player);
            //        playerRepository.Save();
            //    }
            //}

            //username = await userManager.FindByNameAsync("viz");
            //if (username == null)
            //{
            //    User user = new User
            //    {
            //        UserName = "******",
            //        Email = "*****@*****.**",
            //        Gender = Gender.Male,
            //        RegistrationDate = DateTime.Now,
            //        EmailConfirmed = true
            //    };

            //    var result = await userManager.CreateAsync(user, "asdasd");
            //    if (result.Succeeded)
            //    {
            //        Player player = new Player
            //        {
            //            UserId = user.Id,
            //            UserName = user.UserName
            //        };
            //        playerRepository.CreatePlayer(player);
            //        playerRepository.Save();
            //    }
            //}
        }
Exemplo n.º 15
0
 public Task <Player> Register()
 {
     return(_playerRepository.CreatePlayer());
 }
Exemplo n.º 16
0
        public Player GetNewPlayer(string login, string password)
        {
            var player = repoPlayer.CreatePlayer(login, password);

            return(player);
        }
Exemplo n.º 17
0
 public void RegsiterPlayer1(string name)
 {
     _player1       = _playerRepo.CreatePlayer(name);
     _currentPlayer = _player1;
 }
Exemplo n.º 18
0
 public async Task <IActionResult> Post([FromBody] Player player)
 => await Task.Run(() => Ok(new { player = _repo.CreatePlayer(player: player) }));