public async void UpdateVideoUrlInAttachment(int attachmentId, string videoUrl) { RouteAttachment attachment = _dbContext.RouteAttachments.First(att => att.RouteAttachmentID == attachmentId); attachment.VideoUrl = videoUrl; await _dbContext.SaveChangesAsync(); }
public async void UpdateImageAttachments(int attachmentId, params string[] relativeImagePaths) { RouteAttachment attachmentToAddImagesTo = _dbContext.RouteAttachments.First(attachment => attachment.RouteAttachmentID == attachmentId); foreach (string relativeImagePath in relativeImagePaths) { _dbContext.AttachmentPathRelations.Add(new AttachmentPathRelation { ImagePath = relativeImagePath, RouteAttachment = attachmentToAddImagesTo }); } await _dbContext.SaveChangesAsync(); }
/// <summary> /// Adds an attachment to the given route. The attachment consists a video url and relative paths to the images that was added. /// </summary> /// <param name="route">The route to where the attachment is added.</param> /// <param name="videoUrl">The video url added to the attachment.</param> /// <param name="relativeImagePaths">The relative image paths to the images on the server.</param> public void AddAttachment(Route route, string videoUrl, string[] relativeImagePaths) { RouteAttachment attachment = new RouteAttachment { VideoUrl = videoUrl, Route = route, RouteID = route.ID }; _dbContext.RouteAttachments.Add(attachment); foreach (string relativeImagePath in relativeImagePaths) { _dbContext.AttachmentPathRelations.Add(new AttachmentPathRelation { ImagePath = relativeImagePath, RouteAttachment = attachment }); } _dbContext.SaveChanges(); }