示例#1
0
        public async Task <IActionResult> Create([FromBody] CreateUserBody body)
        {
            try
            {
                var entity = await _unitOfWork.Users.GetAsync(x => x.Id == body.Id);

                if (entity != null)
                {
                    return(Payloader.Fail(PayloadCode.Duplication));
                }

                var newEntity = new User
                {
                    Id    = body.Id,
                    Name  = body.Name,
                    Money = 1000,
                };

                await UpdateCube(newEntity);

                await _unitOfWork.Users.AddAsync(newEntity);

                await _unitOfWork.CommitAsync();

                return(Payloader.Success(_mapper.Map <UserViewModel>(newEntity)));
            }
            catch (Exception ex)
            {
                return(Payloader.Error(ex));
            }
        }
        public Payloader <UserViewModel> CreateUser(CreateUserBody body)
        {
            var url = string.Format("api/users");

            return(http.Post <UserViewModel>(GetUri(url), body).Callback(
                       success: (data) =>
            {
                ServerInfo.User = data;
            }));
        }
示例#3
0
        private void Register()
        {
            var id   = ServerInfo.userId; //var id = SystemInfo.deviceUniqueIdentifier;
            var name = name_input.text;

            var body = new CreateUserBody()
            {
                Id   = id,
                Name = name,
            };

            LobbyServer.sInstance?.CreateUser(body).Callback(
                success: (data) =>
            {
                GameServer.sInstance.Connect();
            });
        }