public async Task <FlareMessage> CreateFlareMessage(FlareMessage message, FlareMessageType messageType) { if (!ValidateFlareMessage(message)) { throw new ArgumentException("Invalid Flare Message"); } if (message.Id == Guid.Empty) { message.Id = Guid.NewGuid(); } if (string.IsNullOrWhiteSpace(message.Token)) { CryptoProvider crypt = new CryptoProvider(); message.Token = crypt.CreateUrlKey(); } if (messageType == FlareMessageType.Email) { message.MessageType = "email"; } else if (messageType == FlareMessageType.Sms) { message.MessageType = "sms"; } else if (messageType == FlareMessageType.PhoneCall) { message.MessageType = "phone"; } message = await FlareMessageRepository.Create(message); return(message); }