示例#1
0
        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);
            }
        }
示例#3
0
        // *******************************************************************************************************************************
        #region -  CRUD  -

        public Task <string> InsertMessageAsync(ClassScheduleMessageDTO dto)
        => DB.ClassScheduleMessages.TryInsertOneAsync(dto);