public async Task <IActionResult> UserOnline() { // Check if valid user var currentUser = await _identityService.GetCurrentPersonIdentityAsync(); if (currentUser == null) { return(BadRequest(new RequestMessageResponse() { Success = false, Message = "Forbidden" })); } var obj = new UserStatusDto() { Id = currentUser.Id, Email = currentUser.Email, Online = true }; // Send event var result = await pusher.TriggerAsync(PusherConstants.CHANNEL_NAME, PusherConstants.USER_STATUS_EVENT_NAME, obj); // Return OK result return(new OkResult()); }
public IActionResult AddStatus(string account, [FromBody] UserStatusDto userStatusDto) { if (account == null) { return(StatusCode(500, "错误信息")); } var model = _productRepository.GetBuyer(account); if (model == null) { return(BadRequest()); } var status = new UserStatus { Account = userStatusDto.Account, Count = userStatusDto.Count, SeedID = _productRepository.GetSeed(userStatusDto.SeedID).SeedID, Price = _productRepository.GetSeed(userStatusDto.SeedID).Price, SellerID = _productRepository.GetSeed(userStatusDto.SellerID).SellerID }; _productRepository.AddUserStatus(status); if (!_productRepository.Save()) { return(StatusCode(500, "添加错误")); } return(NoContent()); }
private void YODAHub_UserStatusChanged(UserStatusDto msg) { UserStatusChanged?.Invoke( this, new ChatEventArgs <UserStatusDto>(new ChatEventContext(this), msg) ); }
public IActionResult PutUserStatis([FromBody] UserStatusDto userStatusDto, int sellerid, int seedid, string account = "") { if (userStatusDto == null) { return(BadRequest()); } var model = _productRepository.GetUserStatus(account, sellerid, seedid); if (model == null) { return(BadRequest("无数据")); } //var result=new UserStatus //{ // Count=userStatusDto.Count, // SeedID = _productRepository.GetSeed(userStatusDto.SeedID).SeedID, // Price = _productRepository.GetSeed(userStatusDto.SeedID).Price, // SellerID = _productRepository.GetSeed(userStatusDto.SellerID).SellerID //} model.Count = userStatusDto.Count; if (!_productRepository.Save()) { return(StatusCode(500, "失败")); } if (model.Count == 0) { _productRepository.DeleteUserStatus(model); return(Ok("count小于0自动删除")); } return(Ok()); }
async Task <UserStatusDto> GetUserStatusAsync() { var user = await base.Conn.Table <UserStatusDto>().FirstOrDefaultAsync(); if (user == null) { user = new UserStatusDto(); await base.AddAsync <UserStatusDto>(user); } return(user); }