public HttpResponseMessage Post(Guid realmKey, [FromUri]string emailTemplateId, Email model)
        {
            var realm = RealmService.GetRealmByKey(realmKey);
            if (realm == null)
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, string.Format("Realm not found.")));

            var emailTemplate = EmailTemplateService.GetAllEmailTemplates(realmKey).FirstOrDefault(e => e.Id == emailTemplateId);
            if (emailTemplate == null)
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, string.Format("Email Template with {0} was not found.", emailTemplateId)));

            var email = new Data.Core.Email();

            foreach (var key in model.Fields.Keys)
                email.Fields[key] = model.Fields[key];

            foreach (var recipient in model.Recipients)
                email.Recipients.Add(new Data.Core.Recipient() {Email = recipient.Email, Name = recipient.Name});

            email = EmailService.Save(email);

            emailTemplate.Emails.Add(email);
            emailTemplate = EmailTemplateService.Save(realmKey, emailTemplate);

            SendMessageToAzure(realmKey, emailTemplate, email);

            return Request.CreateResponse(HttpStatusCode.OK, email);
        }
        public ClientResponse<Email> Create(string emailTemplateId, Email emailTemplate)
        {
            var clientResponse = new ClientResponse<Email>();
            var response = HttpClient.PostAsJsonAsync(string.Format("{0}/EmailTemplates/{1}/Emails", RealmToken, emailTemplateId), emailTemplate).Result;

            clientResponse.StatusCode = response.StatusCode;
            if (response.IsSuccessStatusCode)
                clientResponse.Result = response.Content.ReadAsAsync<Email>().Result;
            else
                clientResponse.Message = response.Content.ReadAsStringAsync().Result;

            return clientResponse;
        }