/// <summary> /// Loads a collection of Workplace objects from the database. /// </summary> /// <returns>A collection containing all of the Workplace objects in the database.</returns> public static WorkplaceCollection LoadCollection(string spName, SqlParameter[] parms) { WorkplaceCollection result = new WorkplaceCollection(); using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(spName, parms)) { while (reader.Read()) { Workplace tmp = new Workplace(); tmp.LoadFromReader(reader); result.Add(tmp); } } return(result); }
public void BtnDeleteSelectedWorkplace() { //If not found if (WorkplaceCollection.Where(x => x == SelectedWorkplace).Count() == 0) { return; } //Find the entryrow Workplace workplace = WorkplaceCollection.FirstOrDefault(x => x == SelectedWorkplace); //Delete from datagrid WorkplaceCollection.Remove(workplace); NotifyOfPropertyChange(() => WorkplaceCollection); // Archives the selected workplace using (var ctx = new DatabaseDir.Database()) { ctx.Workplaces.First(x => x.Id == workplace.Id).Archived = true; ctx.SaveChanges(); } }