public void DeleteProjectEventContext(sp_ProjectEvent_DM InputProjectEvent) { using (VolTeerEntities context = new VolTeerEntities()) { var ProjectEventToRemove = (from n in context.tblProjectEvents where n.EventID == InputProjectEvent.EventID select n).FirstOrDefault(); context.tblProjectEvents.Remove(ProjectEventToRemove); context.SaveChanges(); } }
public void UpdateProjectEventContext(sp_ProjectEvent_DM InputProjectEvent) { using (VolTeerEntities context = new VolTeerEntities()) { var existingProjectEvent = context.tblProjectEvents.Find(InputProjectEvent.EventID); if (InputProjectEvent != null) { existingProjectEvent.StartDateTime = InputProjectEvent.StartDateTime; existingProjectEvent.EndDateTime = InputProjectEvent.EndDateTime; existingProjectEvent.AddrID = InputProjectEvent.AddrID; context.SaveChanges(); } } }
public Guid InsertProjectEventContext(sp_ProjectEvent_DM InputProjectEvent) { using (VolTeerEntities context = new VolTeerEntities()) { var NewProjectEvent = new tblProjectEvent { StartDateTime = InputProjectEvent.StartDateTime, EndDateTime = InputProjectEvent.EndDateTime, AddrID = InputProjectEvent.AddrID }; context.tblProjectEvents.Add(NewProjectEvent); context.SaveChanges(); //Return the id of the newly created record return NewProjectEvent.EventID; } }
public void TestProjectEventCreate() { DateTime StartDate = new DateTime(2014, 05, 01, 10, 0, 0); DateTime EndDate = new DateTime(2014, 05, 02, 11, 0, 0); var ProjectEvent_bll = new sp_ProjectEvent_BLL(); var ProjectEvent_dm = new sp_ProjectEvent_DM(); var Project_bll = new sp_Project_BLL(); var VendAdress_bll = new sp_VendAddress_BLL(); ProjectEvent_dm.StartDateTime = StartDate; ProjectEvent_dm.EndDateTime = EndDate; var allProjects = Project_bll.ListProjects(); Assert.IsTrue(allProjects.Count > 0, "The ListProjects() is broken, or no data in DB"); ProjectEvent_dm.ProjectID = allProjects[0].ProjectID; var allAddresses = VendAdress_bll.ListAddresses(); Assert.IsTrue(allAddresses.Count > 0, "The ListAddresses() is broken, or no data in DB"); ProjectEvent_dm.AddrID = allAddresses[0].AddrID; //var ProjectID = ProjectEvent_bll.InsertEventContext(ref ProjectEvent_dm).ProjectID; //ProjectEvent_dm.ProjectID = ProjectID; //var ProjectEvent_dm_selected = ProjectEvent_bll.ListEvents(ProjectID); //Assert.IsTrue(Equals(ProjectEvent_dm, ProjectEvent_dm_selected)); }
public void UpdateProjectEventContext(sp_ProjectEvent_DM InputProjectEvent) { DAL.UpdateProjectEventContext(InputProjectEvent); }
public Guid InsertProjectEventContext(sp_ProjectEvent_DM InputProjectEvent) { return DAL.InsertProjectEventContext(InputProjectEvent); }
public void DeleteProjectEventContext(sp_ProjectEvent_DM InputProjectEvent) { DAL.DeleteProjectEventContext(InputProjectEvent); }
private static bool Equals(sp_ProjectEvent_DM dm1, sp_ProjectEvent_DM dm2) { return (dm1.ProjectID == dm2.ProjectID && dm1.EventID == dm2.EventID && dm1.StartDateTime == dm2.StartDateTime && dm1.EndDateTime == dm2.EndDateTime && dm1.AddrID == dm2.AddrID ); }
private static List<sp_ProjectEvent_DM> DMsFrom(DataTable dataTable) { var DMs = new List<sp_ProjectEvent_DM>(); for (int i = 0; i < dataTable.Rows.Count; i++) { var returnProjectEvent = new sp_ProjectEvent_DM(); returnProjectEvent.ProjectID = new Guid((string)dataTable.Rows[i]["ProjectID"]); returnProjectEvent.EventID = new Guid((String)dataTable.Rows[i]["EventID"]); returnProjectEvent.StartDateTime = Convert.ToDateTime(dataTable.Rows[i]["StartDateTime"]); returnProjectEvent.EndDateTime = Convert.ToDateTime(dataTable.Rows[i]["EndDateTime"]); returnProjectEvent.AddrID = Convert.ToInt32(dataTable.Rows[i]["AddrID"]); DMs.Add(returnProjectEvent); } return DMs; }