public async Task <string> CreateMessageAsync(CreateClassScheduleMessageCommand cmd) { var dto = new ClassScheduleMessageDTO { ID = Guid.NewGuid(), Name = cmd.Name, Phone = cmd.Phone, Email = cmd.Email, Type = cmd.Type, Message = cmd.Message, CreatedOnUtc = DateTime.UtcNow }; var msgCode = await ClassScheduleMessageDAL.InsertMessageAsync(dto).ConfigureAwait(false); if (msgCode.IsSuccess()) { var subject = $"[mylightangel.com]: Class Schedule message from {dto.Email}"; var body = $"<p>Name: {dto.Name}</p><p>Phone: {dto.Phone}</p><p>Email: {dto.Email}</p><p>Message: {dto.Message}</p>"; msgCode = await EmailSender.SendAsync(subject, body).ConfigureAwait(false); } return(msgCode); }
public async Task Api_ContactMessage_BatchCreate() { for (int i = 1; i < 100; i++) { var cmd = new ClassScheduleMessageDTO { Name = "test_ClassSchedule_name", Phone = "111-222-3333", Email = $"test_email_{i}@sync.co", Type = "test_class_type", Message = "test_message", }; var hr = await ClassScheduleMessageApi.CreateMessageAsync(cmd).ConfigureAwait(false); var rs = await hr.GetResultAsync().ConfigureAwait(false); Assert.IsTrue(rs.IsSuccess()); Assert.IsNotNull(rs); } }
// ******************************************************************************************************************************* #region - CRUD - public Task <string> InsertMessageAsync(ClassScheduleMessageDTO dto) => DB.ClassScheduleMessages.TryInsertOneAsync(dto);