Ejemplo n.º 1
0
        public async Task <ReturnValue> Save(ContactForm contactForm)
        {
            logger.LogDebug("CmsService > Save(contactForm: {0})", contactForm.ToString());

            var returnValue = new ReturnValue($"E-mail saved.");

            try
            {
                logger.LogDebug("New e-mail");
                var message = contactForm.MapToModel();
                message.DateReceived = DateTime.Now;

                await _unitOfWork.Emails.Insert(message);

                await _unitOfWork.Save();

                logger.LogDebug("E-mail saved");
            }
            catch (Exception ex)
            {
                logger.LogError(ex, ex.Message);
                returnValue.SetErrorMessage("An error has occurred while saving the e-mail");
            }

            return(returnValue);
        }