public Pictures UploadPicture(string currentUserId, IEnumerable <TemporaryPictureObject> pictureData) { var user = this.unitOfWork.Users.GetUserById(currentUserId, currentUserId); if (user == null) { throw new Exception("Unable to find user."); } var picture = new Pictures(); picture.OwnerId = user.Id; picture.DateUploaded = DateTime.UtcNow; foreach (var pic in pictureData) { var picToAdd = new PictureResolutions { FileName = pic.FileName, FileUrlId = pic.FileUrlId, Size = pic.Size, Width = pic.Width, Height = pic.Height, }; picture.PictureResolutions.Add(picToAdd); } this.dbContext.Pictures.Add(picture); return(picture); }
public static OutgoingPictureResolution Parse(PictureResolutions x) { if (x == null) { return(null); } return(new OutgoingPictureResolution { Height = x.Height, Width = x.Width, Size = x.Size, BlobUrl = x.PictureUrls?.UrlPrefix + "/" + x.FileName }); }