public async Task GetByIdAndFreelancerIdAndEmployerIdAsyncWhenNoMessageFoundReturnsMessageNotFoundResponse() { //Arrange var mockMessageRepository = GetDefaultIMessageRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); var messageId = 200; var freelancerId = 200; var employerId = 200; mockMessageRepository.Setup(r => r.FindByIdAndFreelancerIdAndEmployerId(messageId, freelancerId, employerId)) .Returns(Task.FromResult <Message>(null)); var service = new MessageService(mockMessageRepository.Object, mockUnitOfWork.Object); //Act MessageResponse result = await service.GetByIdAndFreelancerIdAndEmployerIdAsync(messageId, freelancerId, employerId); var message = result.Message; //Assert message.Should().Be("Message not found"); }
/// <summary> /// Invoke the handler pipeline and process the passed message. /// </summary> /// <param name="context">The agent context.</param> /// <param name="messageContext">The message context.</param> /// <returns></returns> /// <exception cref="Exception">Expected inner message to be of type 'ForwardMessage'</exception> /// <exception cref="AgentFrameworkException">Couldn't locate a message handler for type {messageType}</exception> /// TODO should recieve a message context and return a message context. public async Task <MessageResponse> ProcessAsync(IAgentContext context, MessageContext messageContext) { EnsureConfigured(); var agentContext = context.AsAgentContext(); agentContext.AddNext(messageContext); MessageContext outgoingMessageContext = null; while (agentContext.TryGetNext(out var message) && outgoingMessageContext == null) { outgoingMessageContext = await ProcessMessage(agentContext, message); } var response = new MessageResponse(); response.Write(outgoingMessageContext?.Payload); return(response); }
public async Task SendMessage <T>(string userId, T message) { var m = new MessageResponse <T> { Recipient = new User { Id = userId }, Message = message }; var json = JsonConvert.SerializeObject(m, Formatting.None, new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new SnakeCaseNamingStrategy() } }); var pushContent = new StringContent(json, Encoding.UTF8, "application/json"); await _client.PostAsync(createRequestUri("me/messages"), pushContent); }
public IHttpActionResult GetAllEmployee() { try { List <object> lstObj = new List <object>(); string queryLogin = string.Empty; //SELECT* FROM APTCCRM WHERE meta().id like'DOC%' and docType like'%ProfilePhoto%' string query = @"SELECT email,docType,address,dob,gender,profilePhoto,isActive,keyID,language,fullName,auditInfo ,maritalStatus,notes,nationality,roles,religion,mobNum,telNum From " + _bucket.Name + " as `personelInformation` where meta().id like'individual_%' and isActive=true "; var userDocument = _bucket.Query <IndividualOutPut>(query).ToList(); if (userDocument.Count == 0) { return(Content(HttpStatusCode.NotFound, MessageResponse.Message(HttpStatusCode.NotFound.ToString(), MessageDescriptions.NotFound, ""), new JsonMediaTypeFormatter())); } return(Content(HttpStatusCode.OK, userDocument)); } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, MessageResponse.Message(HttpStatusCode.InternalServerError.ToString(), ex.StackTrace), new JsonMediaTypeFormatter())); } }
public IHttpActionResult GetEmployee(string email) { try { IndividualOutPut userDetails = new IndividualOutPut(); string queryLogin = string.Empty; string query = @"SELECT email,docType,address,dob,gender,profilePhoto,isActive,keyID,language,fullName ,maritalStatus,notes,nationality,religion,mobNum,telNum From " + _bucket.Name + " as `personelInformation` where meta().id like'individual_%' and isActive=true and email='" + email + "' "; var userDocument = _bucket.Query <IndividualOutPut>(query).ToList(); if (userDocument.Count == 0) { return(Content(HttpStatusCode.NotFound, MessageResponse.Message(HttpStatusCode.NotFound.ToString(), MessageDescriptions.NotFound, email), new JsonMediaTypeFormatter())); } return(Content(HttpStatusCode.OK, userDocument)); } catch (Exception ex) { return(Content(HttpStatusCode.InternalServerError, MessageResponse.Message(HttpStatusCode.InternalServerError.ToString(), ex.StackTrace), new JsonMediaTypeFormatter())); } }
public HttpResult Post(CreateMessage request) { // POST does not support update //if (request.Id > 0) // return new HttpResult(HttpStatusCode.NotFound, "POST does not support updating idividual messages."); //var id = request.Id; var ds = new DataStore(); var id = ds.InsertMessage(request); var client = new EmailClient(); var emailResult = client.Send(request); var response = new MessageResponse { Id = id, Success = true }; if (emailResult.Success) { ds.InsertMessageStatus(id, 2); } else { ds.InsertMessageStatus(id, 3, emailResult.Message, emailResult.SmtpException); response.Result = emailResult.Message; response.Success = false; } var result = new HttpResult(response) { StatusCode = HttpStatusCode.Created, StatusDescription = RequestContext.AbsoluteUri.CombineWith(id) }; return result; }
public CloseEventArgs(MessageResponse res) { Response = res; }
private void EntMessageEvent(MessageResponse response) { try { if (response != null) { if (response.type != 3 && response.type != 6) { Message msg = new Message(); MessageStyle ms = new MessageStyle(response.style); msg.CreateTime = response.date; msg.FromJid = response.from_jid; msg.MessageBlocks = this.utilService.MessageDecode(response.message); msg.MessageString = response.message; msg.Style = ms; msg.VOType = response.type; msg.MessageObjectType = MessageActorType.EntStaff; this.AutoReplyProcessor(msg); if (this.IsNotifyFlashing(msg)) { NotifyIconUtil.Instance.SetFlashIcon(FlashIconType.EntStaff); NotifyIconUtil.Instance.StartFlashing(); this.dataModel.AddMessage((long)((ulong)Jid.GetUid(msg.FromJid)), MessageActorType.EntStaff, msg); if (this.IsAddMessageBox()) { MessageBoxWindow mbw = this.dataModel.GetMessageBox(); if (mbw == null) { mbw = new MessageBoxWindow(); this.dataModel.SetMessageBox(mbw); } mbw.Refresh(); mbw.Show(); } } else { this.StaffAddMessage(msg); } INWindow inWindow = this.dataService.INWindow as INWindow; if (inWindow != null) { inWindow.Employee.RecentLinkListItem.AddRecentLink(RecentLinkType.EntStaffChat, (long)((ulong)Jid.GetUid(msg.FromJid))); } } } } catch (System.Exception ex) { System.Console.WriteLine(ex.ToString()); } }
public MessageResponse SendMessage(MessageRequest request) { var response = new MessageResponse(); if (this.ValidateMessageRequest(request)) { try { var message = new MailMessage(); foreach (var address in request.ToAddresses) { if (string.IsNullOrWhiteSpace(address.DisplayName)) { message.To.Add(new MailAddress(address.Address)); } else { message.To.Add(new MailAddress(address.Address, address.DisplayName)); } } if (string.IsNullOrWhiteSpace(request.FromName)) { message.From = new MailAddress(request.FromAddress); } else { message.From = new MailAddress(request.FromAddress, request.FromName); } message.Subject = request.Subject; if (request.MessageUrl != null) { using (var client = new WebClient()) { message.Body = client.DownloadString(request.MessageUrl.AbsoluteUri); } } else { message.Body = request.Message; } message.IsBodyHtml = request.IsHtml; var smtp = new SmtpClient(); smtp.Send(message); response.Status = StatusCode.OK; } catch (Exception ex) { response.Status = StatusCode.InternalServerError; this.exceptionHandler.HandleException(ex); } } else { response.Status = StatusCode.BadRequest; } return response; }