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; })); }
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(); }); }