void Save_Click(object sender, EventArgs e) { Assignment assgn = null; using (WindchimeEntities wce = new WindchimeEntities()) { if (id != null) { assgn = (from Assignment a in wce.PermissionableEntities.OfType<Assignment>() where a.EntityID == id select a).FirstOrDefault(); } if (assgn == null) { assgn = new Assignment(); wce.AddToPermissionableEntities(assgn); } assgn.Summary = Summary_box.Text; assgn.Name = Name_box.Text; assgn.DueDate = DateTime.Parse(DueDate_box.Text); assgn.Location = Location_box.Text; if (Completed_chk.Checked && assgn.CompletedDate == null) assgn.CompletedDate = DateTime.Now; else if (!Completed_chk.Checked) assgn.CompletedDate = null; wce.SaveChanges(); wce.Refresh(System.Data.Objects.RefreshMode.StoreWins, assgn); id = assgn.EntityID; } }
public List<Asset> getPublishedAssignmentAssets(Assignment a) { List<Asset> assets = (from Asset ast in a.Children.OfType<Asset>() where ast.Published == true select ast).ToList<Asset>(); return assets; }