public void SavePhoto(Photo photo) { EnsureValid(photo, "Name", "Description", "Category", "Price"); if (photo.PhotoID == 0) _photoesTable.InsertOnSubmit(photo); else { _photoesTable.Attach(photo); _photoesTable.Context.Refresh(RefreshMode.KeepCurrentValues, photo); } _photoesTable.Context.SubmitChanges(); }
public void Is_Comment_Adds_To_Photo() { // Arrage Photo photo = new Photo(); Comment comment = new Comment { Author = "Mike", Text = "Hello world" }; // Act photo.AddComment(comment); // Assert Assert.IsNotNull(photo.Comments[0]); Assert.AreEqual(photo.Comments[0].Author, comment.Author); Assert.AreEqual(photo.Comments[0].Text, comment.Text); }
public void DeletePhoto(Photo photo) { _photoesTable.DeleteOnSubmit(photo); _photoesTable.Context.SubmitChanges(); }