/// <summary> /// DeleteVolunteerContext - Will do a soft delete (make inactive) by VolID /// </summary> /// <param name="_cVolunteer"></param> public void DeleteProjectContext(sp_Project_DM _cProject) { using (VolTeerEntities context = new VolTeerEntities()) { var ProjectToRemove = (from n in context.tblProjects where n.ProjectID == _cProject.ProjectID select n).FirstOrDefault(); context.tblProjects.Remove(ProjectToRemove); context.SaveChanges(); } }
/// <summary> /// InsertVolunteerContext - Will insert a record into Volunteer table via SProc /// </summary> /// <param name="_cVolunteer"></param> public sp_Project_DM InsertProjectContext(ref sp_Project_DM _cProject) { using (VolTeerEntities context = new VolTeerEntities()) { var cProject = new tblProject { ProjectID = _cProject.ProjectID, ProjectName = _cProject.ProjectName, ProjectDesc = _cProject.ProjectDesc, AddrID = _cProject.AddrID, ActiveFlg = _cProject.ActiveFlg }; context.tblProjects.Add(cProject); context.SaveChanges(); return _cProject; } }
public void TestProjectCreate() { string ProjectName = "TestProject"; string ProjectDesc = "We Rock!"; bool ActiveFlg = true; var Project_bll = new sp_Project_BLL(); var Project_dm = new sp_Project_DM(); var VendAdress_bll = new sp_VendAddress_BLL(); Project_dm.ProjectName = ProjectName; Project_dm.ProjectDesc = ProjectDesc; var allAddresses = VendAdress_bll.ListAddresses(); Assert.IsTrue(allAddresses.Count > 0, "The ListAddresses() is broken, or no data in DB"); Project_dm.AddrID = allAddresses[0].AddrID; Project_dm.ActiveFlg = ActiveFlg; var ProjectID = Project_bll.InsertProjectContext(ref Project_dm).ProjectID; Project_dm.ProjectID = ProjectID; var Project_dm_selected = Project_bll.ListProjects(ProjectID); Assert.IsTrue(Equals(Project_dm, Project_dm_selected)); }
public void UpdateProjectContext(sp_Project_DM _cProject) { dal.UpdateProjectContext(_cProject); }
public sp_Project_DM InsertProjectContext(ref sp_Project_DM _cProject) { return dal.InsertProjectContext(ref _cProject); }
public void DeleteProjectContext(sp_Project_DM _cProject) { dal.DeleteProjectContext(_cProject); }
/// <summary> /// UpdateSampleAddressContext - Will update a given Volunteer record by VolID /// </summary> /// <param name="_cVolunteer"></param> public void UpdateProjectContext(sp_Project_DM _cProject) { using (VolTeerEntities context = new VolTeerEntities()) { var cProject = context.tblProjects.Find(_cProject.ProjectID); if (cProject != null) { cProject.ProjectDesc = _cProject.ProjectDesc; cProject.ProjectName = _cProject.ProjectName; cProject.ProjectID = _cProject.ProjectID; cProject.ActiveFlg = _cProject.ActiveFlg; context.SaveChanges(); } } }
protected void saveForm() { sp_Project_DM projectDM = new sp_Project_DM(); sp_VendorProjContact_DM vpContactDM = new sp_VendorProjContact_DM(); vpContactDM.VendorID = (Guid)currentUser.ProviderUserKey; Guid projectID = Guid.NewGuid(); vpContactDM.ProjectID = projectID; int contectIndex = rCBContact.SelectedIndex; if (rCBContact.SelectedIndex != 0) { vpContactDM.ContactID = contacts.ElementAt(rCBContact.SelectedIndex - 1).ContactID; //we can't set a contact as primary if there isn't a contact selected vpContactDM.PrimaryContact = cbPrimaryContact.Checked; } if (rCBAddress.SelectedIndex != 0) { projectDM.AddrID = addresses.ElementAt(rCBAddress.SelectedIndex - 1).AddrID; } projectDM.ProjectID = projectID; projectDM.ProjectName = rTBProjName.Text; projectDM.ProjectDesc = rTBProjDesc.Text; projectDM.ActiveFlg = false; sp_Project_BLL projectBLL = new sp_Project_BLL(); sp_VendorProjContact_BLL vpContactBLL = new sp_VendorProjContact_BLL(); //Why is it by ref? That's weird. projectBLL.InsertProjectContext(ref projectDM); vpContactBLL.InsertContactContext(vpContactDM); }
private static bool Equals(sp_Project_DM dm1, sp_Project_DM dm2) { return (dm1.ProjectID == dm2.ProjectID && dm1.ProjectName == dm2.ProjectName && dm1.ProjectDesc == dm2.ProjectDesc && dm1.AddrID == dm2.AddrID && dm1.ActiveFlg == dm2.ActiveFlg ); }
private static List<sp_Project_DM> DMsFrom(DataTable dataTable) { var DMs = new List<sp_Project_DM>(); for (int i = 0; i < dataTable.Rows.Count; i++) { var returnProject = new sp_Project_DM(); returnProject.ProjectID = new Guid((string)dataTable.Rows[i]["ProjectID"]); returnProject.ProjectName = (String)dataTable.Rows[i]["ProjectName"]; returnProject.ProjectDesc = (String)dataTable.Rows[i]["ProjectDesc"]; returnProject.AddrID = Convert.ToInt32(dataTable.Rows[i]["AddrID"]); returnProject.ActiveFlg = Convert.ToBoolean(dataTable.Rows[i]["ActiveFlg"]); DMs.Add(returnProject); } return DMs; }