public async Task <IActionResult> CreateProviderAttendedModality( [FromServices] ILoggedUserAcessor userLoggedAcessor, [FromBody] CreateAttendedModalityCommand command) { var res = await _mediator.Send(command.ByProviderUserId(userLoggedAcessor.UserId)); return(await ResponseOkIfNotExistsNotificationsAsync(res)); }
public FindAttendedModalitiesByTypeQueryHandler( IAttendedModalityRepository attendedModalityRepository, IContractingUserRepository userRepository, ILoggedUserAcessor userAccessor, IMapper mapper) { _attendedModalityRepository = attendedModalityRepository; _userRepository = userRepository; _userAccessor = userAccessor; _mapper = mapper; }
public async Task <IActionResult> GetMessageOfUser( [FromRoute] string id, [FromServices] ILoggedUserAcessor userLoggedAcessor) { var userType = userLoggedAcessor.Type; Func <ChatMessage, bool> predicate = (x) => x.ClientId == userLoggedAcessor.UserId; Func <ChatMessage, bool> predicateDestination = (x) => x.ProviderId == id.SafeParse(); if (userType == UserType.Provider) { predicate = (x) => x.ProviderId == userLoggedAcessor.UserId; predicateDestination = (x) => x.ClientId == id.SafeParse(); } var messages = _chatContext.Messages .Where(predicate) .Where(predicateDestination) .OrderBy(x => x.SendedAt); return(await ResponseOkAsync(messages)); }
public async Task <IActionResult> GetNegociations([FromServices] ILoggedUserAcessor userLoggedAcessor) { var userType = userLoggedAcessor.Type; Func <ChatMessage, bool> predicate = (x) => x.ClientId == userLoggedAcessor.UserId; Func <ChatMessage, bool> predicateUserName = (x) => x.IsProviderSend == true; Func <ChatMessage, (string providerId, string clientId)> select = (x) => (x.ProviderId.ToString(), x.ClientId.ToString()); if (userType == UserType.Provider) { predicate = (x) => x.ProviderId == userLoggedAcessor.UserId; predicateUserName = (x) => x.IsProviderSend == false; } var userName = (from mess in _chatContext.Messages where predicate(mess) where predicateUserName(mess) select mess.SenderName).FirstOrDefault(); if (userName == null) { return(await ResponseOkAsync(new List <ChatMessage>())); } var messages = from mess in _chatContext.Messages where predicate(mess) group mess by @select(mess) into grp let lastMessage = grp.OrderByDescending(x => x.SendedAt).FirstOrDefault() select new { UserId = userType == UserType.Provider ? grp.Key.clientId : grp.Key.providerId, UserName = userName, lastMessage.IsProviderSend, lastMessage.Content, lastMessage.IsAttachment }; return(await ResponseOkAsync(messages)); }
public async Task <IActionResult> FindProviderAttendedModalities([FromServices] ILoggedUserAcessor userLoggedAcessor) { var res = await _mediator.Send(new FindProviderAttendedModalitiesQuery(userLoggedAcessor.UserId)); return(await ResponseOkIfNotExistsNotificationsAsync(res)); }
public ContractingUserController(IMediator mediator, ILoggedUserAcessor userLoggedAcessor, NotificationContext notificationContext) : base(mediator, notificationContext) { _userLoggedAccessor = userLoggedAcessor; }
public ChatHub(IChatMessageRepository chatRepository, ILoggedUserAcessor acessor) { _chatRepository = chatRepository; _acessor = acessor; }