public void SavePostedImage(HttpPostedFileBase postedImage) { var image = new Image { UploadTime = DateTime.Now, Data = new byte[postedImage.ContentLength] }; postedImage.InputStream.Read(image.Data, 0, image.Data.Length); imageRepository.AddOrUpdate(image); }
private async Task SaveImageAsync(ImageFullModel imageFullModel) { try { List <ImageTagEntity> savedTags = await SaveTagsAsync(imageFullModel.Tags); var imageEntity = new ImageEntity { ExternalId = imageFullModel.Id, Author = imageFullModel.Author, Camera = imageFullModel.Camera, CroppedPicture = imageFullModel.Cropped_picture, FullPicture = imageFullModel.Full_picture, ImageTags = savedTags }; await imageRepository.AddOrUpdate(imageEntity); } catch (Exception ex) { logger.LogError($"Image with Id={imageFullModel.Id} could not be saved. {ex}"); } }