public async Task <AddImagePayload> AddImageAsync( AddImageInput input, [ScopedService] TenantFileContext context) { var(fileName, thumb, tenantId, residenceId, labels) = input; var image = new Image { Name = fileName, Labels = labels, ThumbnailName = thumb, }; context.Images.Add(image); var phones = context.Phones.AsQueryable() .Where(p => p.Tenants.Select(t => t.Id).Contains(tenantId)).ToList(); phones.ForEach(p => p.Images.Add(image)); await context.SaveChangesAsync(); return(new AddImagePayload(image)); }
public async Task <ImageAddedResult> AddImageToPage(AddImageInput input) { var specialFolder = $"/Content/PageImages/{input.PageId}/{input.Lang}"; var fileSavedInfo = await _fileStoreManager.SaveFile(new FileManagerServiceInput() { CreateUniqueName = true, File = input.Image, VirtualFolder = specialFolder }, false); var imageInfo = _fileStoreManager.GetImageInfo(fileSavedInfo.AbsolutePath); return(new ImageAddedResult() { Size = new[] { imageInfo.Width.ToString(), imageInfo.Height.ToString() }, Url = fileSavedInfo.VirtualPath, }); }