private void attach_Photos(Photo entity) { this.SendPropertyChanging(); entity.Date = this; }
private void detach_Photos(Photo entity) { this.SendPropertyChanging(); entity.Date = null; }
partial void DeletePhoto(Photo instance);
partial void UpdatePhoto(Photo instance);
partial void InsertPhoto(Photo instance);
private void photoChooserTask_Completed(object sender, PhotoResult e) { if (e.TaskResult == TaskResult.OK) { byte[] imageBytes = new byte[e.ChosenPhoto.Length]; Guid guid = Guid.NewGuid(); string fileName = string.Format("DatePicture\\{0}", guid.ToString()); Photo p1 = new Photo() { DateId = ((DateViewModel)this.DataContext).Date.Id, Description = "Description", FileName = fileName, CreatedDate = DateTime.Now.ToString() }; ((DateViewModel)this.DataContext).Ctx.Photos.InsertOnSubmit(p1); int ScreenWidth = Int32.Parse(System.Windows.Application.Current.Host.Content.ActualWidth.ToString()); int ScreenHeight = Int32.Parse(System.Windows.Application.Current.Host.Content.ActualHeight.ToString()); ImageInfo fullImage = new ImageInfo() { Directory = "DatePicture", FileName = string.Format("{0}.jpg", guid.ToString()), IsSquare = false, Height = ScreenHeight, Width = ScreenWidth }; ImageInfo thumbnail = new ImageInfo() { Directory = "DatePicture", FileName = string.Format("{0}Small.jpg", guid.ToString()), IsSquare = true, Height = 136, Width = 136 }; Storage.WriteImageToIsolatedStorage(e.ChosenPhoto, new List<ImageInfo>() { thumbnail, fullImage }); //Storage.WriteImageToIsolatedStorage(e.ChosenPhoto, new List<ImageInfo>() { new ImageInfo() { Directory = "DatePicture", FileName = string.Format("{0}Small.jpg", guid.ToString()), Height = 136, Width = 136 } }); ((DateViewModel)this.DataContext).Ctx.SubmitChanges(); } }
public void DeletePhoto(Photo photo) { Ctx.Photos.DeleteOnSubmit(photo); Storage.DeleteFile(string.Format("{0}Small.jpg", photo.FileName)); SubmitChanges(); }