/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { CreateTemplateResponse response = new CreateTemplateResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if (context.TestExpression("CreateTemplateResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return(response); }
public async Task <ActionResult <CreateTemplateResponse> > Post([FromRoute] string clientID, [FromBody] CreateTemplateRequest request) { CreateTemplateResponse response = new CreateTemplateResponse(); string responseMessage = $"CREATE_{clientID}_TEMPLATE_{request.Title}"; try { var dto = new TemplateDTO { ClientID = clientID, Title = request.Title, Description = request.Description, Page = request.Page, Content = request.Content }; var factory = Factory.Instance.GetTemplate(_configuration); await factory.Save(dto.Adapt()); response.StatusCode = "200"; response.Data = $"Template {request.Title} created with success"; return(Ok(response)); } catch (Exception ex) { response.StatusCode = "500"; response.Messages.Add(ResponseMessage.Create(ex, responseMessage)); return(StatusCode(500, response)); } }
public static CreateTemplateResponse Unmarshall(UnmarshallerContext context) { CreateTemplateResponse createTemplateResponse = new CreateTemplateResponse(); createTemplateResponse.HttpResponse = context.HttpResponse; createTemplateResponse.RequestId = context.StringValue("CreateTemplate.RequestId"); createTemplateResponse.TemplateType = context.StringValue("CreateTemplate.TemplateType"); CreateTemplateResponse.CreateTemplate_Template template = new CreateTemplateResponse.CreateTemplate_Template(); template.TemplateName = context.StringValue("CreateTemplate.Template.TemplateName"); template.TemplateId = context.StringValue("CreateTemplate.Template.TemplateId"); template.CreatedDate = context.StringValue("CreateTemplate.Template.CreatedDate"); template.CreatedBy = context.StringValue("CreateTemplate.Template.CreatedBy"); template.UpdatedDate = context.StringValue("CreateTemplate.Template.UpdatedDate"); template.UpdatedBy = context.StringValue("CreateTemplate.Template.UpdatedBy"); template.Hash = context.StringValue("CreateTemplate.Template.Hash"); template.Description = context.StringValue("CreateTemplate.Template.Description"); template.ShareType = context.StringValue("CreateTemplate.Template.ShareType"); template.TemplateFormat = context.StringValue("CreateTemplate.Template.TemplateFormat"); template.TemplateVersion = context.StringValue("CreateTemplate.Template.TemplateVersion"); template.HasTrigger = context.BooleanValue("CreateTemplate.Template.HasTrigger"); template.Tags = context.StringValue("CreateTemplate.Template.Tags"); createTemplateResponse.Template = template; return(createTemplateResponse); }
public static CreateTemplateResponse Unmarshall(UnmarshallerContext context) { CreateTemplateResponse createTemplateResponse = new CreateTemplateResponse(); createTemplateResponse.HttpResponse = context.HttpResponse; return(createTemplateResponse); }
public static CreateTemplateResponse Unmarshall(UnmarshallerContext _ctx) { CreateTemplateResponse createTemplateResponse = new CreateTemplateResponse(); createTemplateResponse.HttpResponse = _ctx.HttpResponse; createTemplateResponse.RequestId = _ctx.StringValue("CreateTemplate.RequestId"); createTemplateResponse.TemplateId = _ctx.StringValue("CreateTemplate.TemplateId"); return(createTemplateResponse); }
public static CreateTemplateResponse Unmarshall(UnmarshallerContext context) { CreateTemplateResponse createTemplateResponse = new CreateTemplateResponse(); createTemplateResponse.HttpResponse = context.HttpResponse; createTemplateResponse.RequestId = context.StringValue("CreateTemplate.RequestId"); createTemplateResponse.TemplateId = context.IntegerValue("CreateTemplate.TemplateId"); return(createTemplateResponse); }
public void CreateOrUpdateEmailTemplate(string templateName, string subject, string text, string html) { using (AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(_regionEndpoint)) { Template template = new Template { TemplateName = templateName, SubjectPart = subject, TextPart = text, HtmlPart = html }; CreateTemplateRequest createTemplateRequest = new CreateTemplateRequest { Template = template }; try { _logger.LogInformation($"CreateOrUpdateEmailTemplate | TemplateName = {createTemplateRequest.Template.TemplateName}"); CreateTemplateResponse createTemplateResponse = client.CreateTemplateAsync(createTemplateRequest).Result; _logger.LogInformation($"CreateTemplateResponse.StatusCode = {createTemplateResponse.HttpStatusCode}"); _logger.LogInformation($"CreateTemplateResponse.RequestId = {createTemplateResponse.ResponseMetadata.RequestId}"); _logger.LogInformation($"CreateTemplateResponse.Metadata = {string.Join("; ", createTemplateResponse.ResponseMetadata.Metadata)}"); } catch (Exception ex) { if (ex.InnerException.GetType() == typeof(AlreadyExistsException)) { _logger.LogInformation($"Template already exists, updating template content for {templateName}"); try { UpdateTemplateResponse updateTemplateResponse = client.UpdateTemplateAsync(new UpdateTemplateRequest { Template = template }).Result; _logger.LogInformation($"UpdateTemplateResponse.StatusCode = {updateTemplateResponse.HttpStatusCode}"); _logger.LogInformation($"UpdateTemplateResponse.RequestId = {updateTemplateResponse.ResponseMetadata.RequestId}"); _logger.LogInformation($"UpdateTemplateResponse.Metadata = {string.Join("; ", updateTemplateResponse.ResponseMetadata.Metadata)}"); } catch { throw; } } else { _logger.LogError("Failure in CreateOrUpdateTemplate. Error message: " + ex.Message); throw ex; } } } }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateTemplateResponse response = new CreateTemplateResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Arn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Arn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("CreationStatus", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.CreationStatus = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("RequestId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.RequestId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("TemplateId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.TemplateId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("VersionArn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.VersionArn = unmarshaller.Unmarshall(context); continue; } } response.Status = (int)context.ResponseData.StatusCode; return(response); }
private static void UnmarshallResult(XmlUnmarshallerContext context, CreateTemplateResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { } } return; }
public async Task <bool> CreateTemplate(string templatename, string subject, string body, string html) { Template template = new Template() { TemplateName = templatename, SubjectPart = subject, TextPart = body, HtmlPart = html }; _templaterequest = new CreateTemplateRequest { Template = template }; _templateresponse = await _Client.CreateTemplateAsync(_templaterequest); if (_templateresponse.HttpStatusCode.ToString() == "OK") { return(true); } return(false); }