public async Task <UserMessageDto> PutUserMessage(int id, UserMessageDto model) { var url = CRMApiUri + "/UserMessage/" + id; var result = await PutRequestToApi(url, model); return(result); }
//public IActionResult Comment(CommentDto commentDto) //{ // commentDto.PostId = (int)HttpContext.Session.GetInt32("PostId"); // commentDto.UserId =userService.GetUserByName(User.Identity.Name).Id; // postService.Comment(commentDto); //} public IActionResult ShowChat(string username) { string CurrentUser = User.Identity.Name; UserMessageDto UserMessages = messageService.GetMessages(CurrentUser, username); return(PartialView("Chat", UserMessages)); }
public async Task <UserMessageDto> PostUserMessage(UserMessageDto model) { var url = CRMApiUri + "/UserMessage"; var result = await PostRequestToApi(url, model); return(result); }
public async Task <BaseEntity> SaveAndReturnEntityAsync(UserMessageDto entityDto) { var entity = _mapper.Map <UserMessage>(entityDto); var result = await _repository.SaveAndReturnEntityAsync(entity); return(result); }
public async Task <IActionResult> Put(int id, [FromBody] UserMessageDto userMessage) { if (id == 0 || userMessage.Id == 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Id needs to be greater than 0.")); } return(await SaveAndReturnEntityAsync(async() => await _userMessageService.SaveAndReturnEntityAsync(userMessage))); }
public async Task <IActionResult> Post([FromBody] UserMessageDto userMessage) { if (userMessage.Id != 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Identity insert is not permitted.")); } return(await SaveAndReturnEntityAsync(async() => await _userMessageService.SaveAndReturnEntityAsync(userMessage))); }
public UserMessageDto GetMessages(string currentUser, string username) { UserMessageDto userMessageDto = new UserMessageDto(); List <MessageDto> messageDtoList = new List <MessageDto>(); User CurrentUser = _context.Users.Where(u => u.UserName == currentUser).FirstOrDefault(); User TargetUser = _context.Users.Where(u => u.UserName == username).FirstOrDefault(); List <Message> messages = _context.Messages.Where(m => (m.OwnerUserId == CurrentUser.Id && m.SentTo == TargetUser.Id) || (m.OwnerUserId == TargetUser.Id && m.SentTo == CurrentUser.Id)).ToList(); foreach (var item in messages) { MessageDto messageDto = new MessageDto(); User user = new User(); user = _context.Users.Where(u => u.Id == item.OwnerUserId).FirstOrDefault(); messageDto.CreatedDate = item.CreatedDate; messageDto.Id = item.Id; messageDto.OwnerUserId = item.OwnerUserId; messageDto.SentTo = item.SentTo; messageDto.Text = item.Text; messageDto.UserPhoto = user.ProfilePhoto; messageDto.OwnerUserName = user.UserName; messageDtoList.Add(messageDto); } UserDto TargetUserDto = new UserDto(); TargetUserDto.Email = TargetUser.Email; TargetUserDto.Id = TargetUser.Id; TargetUserDto.Name = TargetUser.Name; TargetUserDto.Surname = TargetUser.Surname; TargetUserDto.ProfileImage = TargetUser.ProfilePhoto; TargetUserDto.UserName = TargetUser.UserName; userMessageDto.TargetUser = TargetUserDto; userMessageDto.Messages = messageDtoList; return(userMessageDto); }
public async Task Send(UserMessageDto userMessage) => await Clients.All.Send(userMessage);
public UserMessageAPIPayload(UserMessageDto userMessage) { _userMessage = userMessage; }
public async Task <int> SaveAsync(UserMessageDto entityDto) { var result = await SaveAndReturnEntityAsync(entityDto); return(result.Id); }
public async Task <UserMessageDto> PutUserMessage(int id, UserMessageDto model) { return(await _userMessageApiClient.PutUserMessage(id, model)); }
public async Task <UserMessageDto> PostUserMessage(UserMessageDto model) { return(await _userMessageApiClient.PostUserMessage(model)); }