public async Task Invoke(HttpContext context, IDocumentClient documentDbClient, IImageRepository imageRepository) { var imagesRepository = new GetRepository <Domain.Tea.Image>(documentDbClient, DocumentDBConstants.DatabaseId, DocumentDBConstants.Collections.Images); var matches = Regex.Matches(context.Request.Path, RegEx); if (matches.Count > 0 && matches[0].Groups.Count > 1) { var image = await imagesRepository.GetItemAsync(matches[0].Groups[1].Value); var bitmap = await imageRepository.Get(image.Filename); var response = GenerateResponse(bitmap, image.Filename); context.Response.ContentType = bitmap.GetMimeType("image/png"); await context.Response.Body.WriteAsync(response, 0, response.Length); } }
public async Task <ICommandResult> ExecuteAsync(UpdateBagCommand command) { var activity = await ActivityRepository.SearchItemsAsync(x => x.Name == $"{nameof(UpdateBagCommandHandler)}"); if (await Authorizer.IsAuthorized(activity.FirstOrDefault())) { return(new ForbidResult()); } if (command == null) { return(new ErrorResult("Update item cannot be null")); } var previousEntity = await GetRepository.GetItemAsync(command.Id); var entity = Translator.Translate(command.Data, previousEntity); await UpdateRepository.UpdateItemAsync(command.Id, entity); return(new OkResult()); }