public async Task Handle(PaymentProcessedEvent message, IMessageHandlerContext context) { // Invoke e - mail notification service INotificationService emailService = _notificationServiceDelegate(NotificationType.Email); // Create order placed message var emailMessage = Message.CreateAsEmail( "Payment for " + message.OrderId + " Completed successfully!", "Your payment has been processed successfully!", "*****@*****.**" ); // Save message await _messageRepository.Create(emailMessage); // Send the message await emailService.Send(emailMessage); }
public async Task Handle(OrderPlacedEvent message, IMessageHandlerContext context) { // Invoke e-mail notification service INotificationService emailService = _notificationServiceDelegate(NotificationType.Email); // Create order placed message var emailMessage = Message.CreateAsEmail( "Order " + message.OrderId + " placed successfully!", "Your order has been received successfully. You will receive another e-mail once your payment has been processed.", "*****@*****.**" ); // Save message await _messageRepository.Create(emailMessage); // Send the message await emailService.Send(emailMessage); }
public async Task Handle(OrderCancelledEvent message, IMessageHandlerContext context) { //throw new Exception("E-mail service unreachable"); // Invoke e - mail notification service INotificationService emailService = _notificationServiceDelegate(NotificationType.Email); // Create order placed message var emailMessage = Message.CreateAsEmail( "Order " + message.OrderId + " Cancelled!", "Your order has been cancelled! If that was an error, please contact customer support at [email protected].", "*****@*****.**" ); // Save message await _messageRepository.Create(emailMessage); // Send the message await emailService.Send(emailMessage); }
public ActionResult Create(Message message) { if (!ModelState.IsValid) //server side validaiton { ModelState.AddModelError("", "You have to fill all requiered fields!."); return(RedirectToAction("ContactUs", "Home")); } try { _messageRepo.Create(message); return(RedirectToAction("Index", "Home")); } catch { return(NotFound()); } }
public async Task <ActionResult> CreateMessage(Message message) { if (ModelState.IsValid) { var ticket = await ticketsRepository.Get(message.TicketId); string userId = User.Identity.GetUserId(); var user = await staffManager.FindByIdAsync(userId); message.CreationDate = DateTime.Now; message.Ticket = ticket; message.StaffMember = user; await messageRepository.Create(message); ticketsMailer.Send(Constants_files.Constants.MAIL_HEADER, string.Format("{0} Link: {1}", Constants_files.Constants.SUPPORT_RESPONSE_ON_TICKET, Url.Action("GetTicket", "Tickets", new { id = ticket.TicketId }, Request.Url.Scheme)), ticket.CustomerEmail); } return(RedirectToRoute("tickets/get/id", new { id = message.TicketId })); }
public Task BroadcastChatMessage(string tag, string text, string type) { User user = _userRepository.GetByLogonUser(Context.User.Identity.Name); Message message = new Message { User = user, Timestamp = DateTime.Now, Tag = new Regex("[^a-zA-Z0-9-]").Replace(tag.ToUpper(), ""), //Upper cased & alphanumeric tags only Text = text, Type = MessageType.Types.FirstOrDefault(f => f == type) //Only allow message types that are defined by us }; message.User.UserID = user.UserID; _messageRepository.Create(message); return(Clients.All.ReceiveChatMessage( message.User.Name, message.User.Division, message.Timestamp, message.Tag, message.Text, message.Type)); }
public void favourite_must_be_enabled_after_toggle() { var message = DatabaseHelper.CreateValidMessage(DatabaseHelper.UserTest4); var userMessage = DatabaseHelper.CreateValidUserMessage(message, DatabaseHelper.UserTest4); _messageRepository.Create(message); _userMessageRepository.Create(userMessage); _unitOfWork.Commit(); _messageFavouriteService.ToggleFavourite(userMessage.User.Id, userMessage.Message); _unitOfWork.Commit(); var favourite = _favouriteUserMessageRepository.FindAll().FirstOrDefault(x => x.User.Id == DatabaseHelper.UserTest4.Id && x.Message.Id == message.Id); Assert.IsNotNull(favourite, "User favourite message must exists after toggle favorite (enable)"); }
public async Task <MessageCreateCommandResponse> Handle(MessageCreateCommandRequest request, CancellationToken cancellationToken) { MessageCreateCommandResponse result = new MessageCreateCommandResponse(); MessageEntity message = await repository.Get(request.IdGroup, request.IdOriginPerson, request.IdDestinationPerson, request.Date); if (message == null) { message = mapper.Map <MessageEntity>(request); await repository.Create(message); result.Entity = await repository.Get(request.IdGroup, request.IdOriginPerson, request.IdDestinationPerson, request.Date); result.Code = 1; result.Message = "Message created"; } else { result.Code = 0; result.Message = "Message already exists"; } return(result); }
public ActionResult Create([FromBody] Message message, [FromHeader(Name = "Accept")] string mediaType) { if (!ModelState.IsValid) { return(UnprocessableEntity()); } _messageRepository.Create(message); if (mediaType == "application/vnd.talkto.hateoas+json") { var messageDTO = _mapper.Map <MessageDTO>(message); messageDTO.Links.Add(new LinkDTO("_self", Url.Link("CreateMessage", null), "POST")); messageDTO.Links.Add(new LinkDTO("_update", Url.Link("PartialUpdateMessage", new { id = message.Id }), "PATCH")); return(Ok(messageDTO)); } else { return(Ok(message)); } }
public void Contact(MessageModel model) { Guard.NotNull(model, nameof(model), Constants.NullExceptionGenerator); _logger.LogInformation($"new message: {JsonConvert.SerializeObject(model)}"); var subject = FormatSubject(model); var body = FormatBody(model); try { _emailSender.SendToSelf(subject, body); } catch (Exception ex) { _logger.LogError(ex, "error sending email"); } var entity = Mapper.Map <Message>(model); _messageRepository.Create(entity); _messageStatusRepository.SetAsUnread(entity.Id); }
public ActionResult <MessageReadDto> Create([FromBody] MessageCreateDto request) { if (_userRepository.Get(request.SenderId) == null || _userRepository.Get(request.ReceiverId) == null) { return(StatusCode(StatusCodes.Status400BadRequest, "User doesn't exist.")); } Conversation conversation = _conversationRepository.Get(request.ConversationId); if (conversation == null) { return(StatusCode(StatusCodes.Status400BadRequest, "Conversation doesn't exist.")); } if (conversation.CreatorId != conversation.ParticipantId && request.SenderId == request.ReceiverId) { return(StatusCode(StatusCodes.Status400BadRequest, "You can't send message to yourself in Conversation with someone else.")); } if ((conversation.CreatorId != request.SenderId && conversation.CreatorId != request.ReceiverId) || (conversation.ParticipantId != request.SenderId && conversation.ParticipantId != request.ReceiverId)) { return(StatusCode(StatusCodes.Status403Forbidden, "Cannot create Message for Conversation you're not a part of.")); } Message newEntity = _mapper.Map <Message>(request); newEntity.DateTime = DateTime.UtcNow; newEntity.StatusRead = false; newEntity = _messageRepository.Create(newEntity); return(StatusCode(StatusCodes.Status201Created, _mapper.Map <MessageReadDto>(newEntity))); }
public void creating_comment_must_create_new_message() { var commentedMessage = DatabaseHelper.CreateValidMessage(DatabaseHelper.UserTest1); _messageRepository.Create(commentedMessage); _unitOfWork.Commit(); Message createdMessage = _messageService.CreateComment("6eff25a0-3305-49fb-a2bf-3d335f892cc0", DatabaseHelper.UserTest1.Id, commentedMessage.Id); _unitOfWork.Commit(); Assert.IsNotNull(createdMessage, "Creating comment must create new message"); }
public async Task Create(Message message) { await _repository.Create(message); }
public void Create(Message message) { message.DateSend = DateTime.Now; _messageRepository.Create(message); }
public void CreateMessage(MessageEntity message) { messageRepository.Create(message.ToDalMessage()); uow.Commit(); }
public int SendMessage(MessageDTO messageDto) { var message = _mapper.Map <MessageDTO, Message>(messageDto); return(_messageRepository.Create(message)); }
public async Task <Message> AddMessage(Message message) { var result = await messageRepository.Create(message); return(result); }
public void SendMessage(int vkId, int inquiryId, string text) { var userId = _userService.GetUserByVkId(vkId).Id; _messageRepository.Create(userId, inquiryId, text); }
public async Task <ActionResult <Message> > CreateMessage([FromBody] Message Message, String FromUserId, String ToUserId) { await _repository.Create(Message, FromUserId, ToUserId); return(CreatedAtRoute("GetMessage", new { id = Message.Id }, Message)); }
public Message Create(Message entity) { return(_MessageRepository.Create(entity)); }
public ActionResult PostMessage([FromBody] MessageCreateDto dto) { var entity = _repository.Create(dto); return(Ok(entity)); }
public void Should_Create_Message_Return_true() { Boolean ret = _messageQueries.Create(MessageQueriesMock.messageCreated); Assert.IsTrue(ret); }
public void transmit_must_create_message_in_direct_observers_main_feed() { var message = DatabaseHelper.CreateValidMessage(DatabaseHelper.UserTest4); var userMessage3 = DatabaseHelper.CreateValidUserMessage(message, DatabaseHelper.UserTest3); _messageRepository.Create(message); _userMessageRepository.Create(userMessage3); _unitOfWork.Commit(); _userMessageService.SendTransmit(DatabaseHelper.UserTest3.Id, message.Id); _userMessageRepository.ReloadEntity(userMessage3); var numberOfAllUser2Messages = _userMessageRepository.FindAll().Count(x => x.User.Id == DatabaseHelper.UserTest2A.Id && x.Message.Id == message.Id); var numberOfOtherUserMessages = _userMessageRepository.FindAll().Count(x => x.User.Id != DatabaseHelper.UserTest2A.Id && x.User.Id != DatabaseHelper.UserTest3.Id && x.Message.Id == message.Id); Assert.AreEqual(1, numberOfAllUser2Messages, "Message must retransmit to usertest2A feed when usertest3 retransmit"); Assert.IsTrue(userMessage3.WasTransmitted, "Retransmitted user message must have set WasTransmitted as true"); Assert.AreEqual(0, numberOfOtherUserMessages, "Message must not retransmit on other users feeds"); }
public ActionResult Create(Message message) { _messageRepository.Create(message); return(RedirectToAction("Index")); }