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, Route(template: "spider-man", Name="spider-man")] | |
| public async Task<IHttpActionResult> SpiderMan(Guid userId) | |
| { | |
| return Ok(await marvelService.GetSpiderMan(Guid userId)); | |
| } | |
| [HttpGet, Route(template: "thanos", Name="thanos")] | |
| public async Task<IHttpActionResult> Thanos(Guid userId) | |
| { | |
| return Ok(await marvelService.GetThanos(Guid userId)); |
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<SpiderManDto> GetSpiderMan(Guid userId) | |
| { | |
| var user = await core.User.GetBy(userId).ConfigureAwait(false); | |
| /////////////////// Repeat 1 //////////////// | |
| var eligibility = Eligibility.Check(user.Dob, user.Subscription); | |
| if (eligibility != UserEligibility.Ok) | |
| { | |
| core.Analytics.ReportUserStatus( |
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 string GetQueryParameterBy(string token) | |
| { | |
| var comparer = StringComparer.OrdinalIgnoreCase; | |
| var superHeroMap = new Dictionary<string, Func<string>>(comparer) { | |
| { QueryStringConstants.SpiderMan, GetSpiderMan }, | |
| { QueryStringConstants.Thanos, GetThanos }, | |
| { QueryStringConstants.IronMan, GetIronMan }, | |
| { QueryStringConstants.CaptainAmerica, GetCaptainAmerica }, | |
| { QueryStringConstants.WandaMaximoff, GetWandaMaximoff }, |
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 string GetQueryParameterBy(string token) | |
| { | |
| string paramValue = null; | |
| if (string.Equals(token, QueryStringConstants.Thanos, | |
| StringComparison.OrdinalIgnoreCase)) | |
| { | |
| paramValue = GetThanos(); | |
| } | |
| else if (string.Equals(token, QueryStringConstants.SpiderMan, |
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 PlainTextMediaTypeFormatter : MediaTypeFormatter | |
| { | |
| public PlainTextMediaTypeFormatter() | |
| { | |
| SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain")); | |
| } | |
| public override bool CanReadType(Type type) => | |
| type == typeof(string); |
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 file = this.fileInput.current.files[0] | |
| console.log(file) | |
| let reader = new FileReader() | |
| reader.onload = () => { | |
| console.log(reader.result) | |
| let charEncoded = '', |
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 FileInB64 | |
| { | |
| public string Name { get; set; } | |
| public string Type { get; set; } | |
| public long? Size { get; set; } | |
| public string B64Str { get; set; } | |
| } |
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 file = this.fileInput.current.files[0] | |
| console.log(file) | |
| let reader = new FileReader() | |
| reader.onload = () => { | |
| console.log(reader.result) | |
| const payload = { |
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
| [HttpPost] | |
| public IHttpActionResult Multipart() | |
| { | |
| if (!Request.Content.IsMimeMultipartContent()) | |
| { | |
| throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); | |
| } | |
| var file = HttpContext.Current.Request.Files.Count > 0 ? | |
| HttpContext.Current.Request.Files[0] : null; |
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
| handleSubmit = e => { | |
| e.preventDefault() | |
| const files = this.fileInput.current.files | |
| let formData = new FormData(e.target) | |
| for(let i = 0; i < files.length; i++) { | |
| formData.append( `file-${i}`, files[i]) | |
| } |