This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Web.Http; | |
| namespace SwaggerDoc | |
| { | |
| public static class WebApiConfig | |
| { | |
| public static void Register(HttpConfiguration config) | |
| { | |
| #region CORS hatası için... | |
| //Normalde diğer projeler için gerekmeye bilir ama burada test ederken CORS hatasına düşmeyecek. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>API Documentation</title> | |
| <!--<link rel="shortcut icon" href="favicon.ico">--> | |
| <!-- needed for adaptive design --> | |
| <meta charset="utf-8"/> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet"> | |
| <!-- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ApplySchemaFilter : ISchemaFilter | |
| { | |
| public void Apply(Schema schema, SchemaRegistry schemaRegistry, Type type) | |
| { | |
| if (schema?.properties == null || type == null) | |
| return; | |
| var excludedProperties = type.GetProperties() | |
| .Where(t => | |
| t.GetCustomAttribute<SwaggerExcludeAttribute>() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ApplyOperationFilter : IOperationFilter | |
| { | |
| public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription) | |
| { | |
| if (operation == null) return; | |
| InitSetContentTypeJson(operation); | |
| InitSchemaOneOf(operation); | |
| InitFromUriParameters(operation, apiDescription); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ApplyDocumentFilter : IDocumentFilter | |
| { | |
| public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer) | |
| { | |
| swaggerDoc.info = GetInfo(); | |
| swaggerDoc.securityDefinitions = GetSecurityDefinitions(); | |
| var tagGroups = GetTagGroups(); | |
| var tagsDescriptions = GetTagsDescription(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [HttpGet] | |
| [SwaggerResponse(System.Net.HttpStatusCode.NotFound, "Customer not found or no access", typeof(ErrorMessageVo))] | |
| public CustomerGetResponseVo Get(int id) | |
| { | |
| return new CustomerGetResponseVo(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private GraphServiceClient CreateGraphClientAsync(string token) | |
| { | |
| return new GraphServiceClient( | |
| new DelegateAuthenticationProvider( | |
| (request) => | |
| { | |
| if (!string.IsNullOrEmpty(token)) | |
| { | |
| request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task<string> CreateDraftMessage(string messageId, IList<string> toEmails, string subject, string body) | |
| { | |
| if (toEmails == null || !toEmails.Any() || string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(body)) | |
| { | |
| return null; | |
| } | |
| var message = new Message | |
| { | |
| Subject = subject, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private async Task DeleteMessage(string messageId) | |
| { | |
| try | |
| { | |
| await graphClient.Me.Messages[messageId] | |
| .Request() | |
| .DeleteAsync(); | |
| } | |
| catch (Exception ex) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var attachment = new FileAttachment | |
| { | |
| Name = fileName, | |
| ContentBytes = bytes | |
| }; | |
| await graphClient.Me.Messages[messageId].Attachments | |
| .Request() | |
| .AddAsync(attachment).ConfigureAwait(false); |
OlderNewer