public dynamic delDiscipleship([FromBody] dynamic currentDiscipleship) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; int id = currentDiscipleship.discipleship.DiscipleshipID; try { //retrieve selected Discipleship thisDiscipleship = db.Discipleships.Where(x => x.DiscipleshipID == id).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = currentDiscipleship.userID; auditLog.EventDescription = "Deleted a Discipleship with ID: " + thisDiscipleship.DiscipleshipID + " and Name: " + thisDiscipleship.DiscipleshipDescription; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); //remove from db db.Discipleships.Remove(thisDiscipleship); //save db.SaveChanges(); return(getAllDiscipleships()); } catch (Exception e) { //else error dynamic toReturn = new ExpandoObject(); toReturn.Error = e.Message; return(toReturn); } }
public void delAnnouncement([FromBody] dynamic announcement) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; int id = announcement.ann.AnnouncementID; List <Person_Announcement> thisAnn = db.Person_Announcement.Where(x => x.AnnouncementID == id).ToList(); try { foreach (Person_Announcement a in thisAnn) { db.Person_Announcement.Remove(a); } Announcement x = db.Announcements.Where(d => d.AnnouncementID == id).FirstOrDefault(); db.Announcements.Remove(x); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = announcement.PersonID; auditLog.EventDescription = "Removed announcement with ID: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); } catch (Exception e) { } }
public dynamic removeHomecellNotes(dynamic HomecellNotesName) //get string parameter { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //establish database connection db.Configuration.ProxyCreationEnabled = false; //configure proxy to eliminate overload of data try { string file = HomecellNotesName.FileName; //retrieve Homecell notes to remove based on selected Homecell notes Homecell_Notes HCNotes = db.Homecell_Notes.Where(z => z.HomecellNotes == file).FirstOrDefault(); db.Homecell_Notes.Remove(HCNotes); //Add to Audit trail entity Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = HomecellNotesName.PersonID; auditLog.EventDescription = "Removed Homecell Notes with with ID: " + HCNotes.HCNID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); } catch (Exception) { return(null); } return(getHomecellNotes()); }
public dynamic delOrgIndivPos([FromBody] dynamic currentOrgIndivPos) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; int id = currentOrgIndivPos.form.OrgIndivPosID; //retrieve selected object Organisational_Individual_Position thisOrgIndivPos = db.Organisational_Individual_Position.Where(x => x.OrgIndivPosID == id).FirstOrDefault(); //remove object db.Organisational_Individual_Position.Remove(thisOrgIndivPos); try { Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = currentOrgIndivPos.PersonID; auditLog.EventDescription = "Removed Organisational Individual Structure Position with ID: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); //save return(getAllOrgIndivPos()); //return all } catch (Exception e) { //else return error dynamic toReturn = new ExpandoObject(); toReturn.Error = e.Message + e.InnerException; return(toReturn); } }
public List <dynamic> checkInChild([FromBody] dynamic confirmationCheckIn) //get JSON parameter { //validate that there is no null values if (confirmationCheckIn != null) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //establish database connection db.Configuration.ProxyCreationEnabled = false; //configure proxy to eliminate overload of data try { foreach (var child in confirmationCheckIn.child) { int id = child; Person_Children childCheckIn = db.Person_Children.Include(x => x.Person).Include(z => z.Child).Where(x => x.ChildID == id).FirstOrDefault(); childCheckIn.KCVolunteerConfirmation = true; childCheckIn.CheckIn = true; childCheckIn.SignOut = false; childCheckIn.CheckInDateTime = DateTime.Now; Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = confirmationCheckIn.PersonID; auditLog.EventDescription = "Checked in child with ID: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); //Save nchanges and Add new position // return called method childrenList += childCheckIn.Child.Name + " " + childCheckIn.Child.Surname + ", "; toName = childCheckIn.Person.Name; toMember = childCheckIn.Person.Email; } message = childrenList + " Has been successfully checked-in of Kids Church at Christian Revival Church (CRC) Main."; Emailsubject = "Kids Church Sign-out @ CRC"; sendEmail(); foreach (var child in confirmationCheckIn.child) { checkInRequestsList.Remove(child); } if (checkInRequestsList.Count() == 0) { return(getChilConfirmation(checkInRequestsList)); } else { return(null); } } catch (Exception) { return(null); } } else { return(null); } }
public dynamic addOrgGroup(dynamic orgGroup) { //Database connection ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //Configure proxy to eliminate overload of data db.Configuration.ProxyCreationEnabled = false; //Dynamic object for return message dynamic returnMessage = new ExpandoObject(); if (orgGroup != null) { if (orgGroup.GroupTypeID == null || orgGroup.Description == "" || orgGroup.Address == "" || orgGroup.SuburbID == null) { return(returnMessage.Message = "Not all the fields were completed. Please ensure that all fields are completed."); } else { try { Organisational_Group group = new Organisational_Group(); group.GroupTypeID = orgGroup.GroupTypeID; group.Description = orgGroup.Description; group.Address = orgGroup.Address; group.SuburbID = orgGroup.SuburbID; db.Organisational_Group.Add(group); db.SaveChanges(); //Add to Audit trail entity string name = orgGroup.Description; Organisational_Group gname = db.Organisational_Group.Where(z => z.Description == name).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = orgGroup.PersonID; auditLog.EventDescription = "Organisational Group added with id: " + gname.OrgGroupID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); return(returnMessage = "All done! We have received the group information."); } catch (Exception) { returnMessage.Message = "Something went wrong! Please try again."; return(returnMessage); } } } else { return(null); } }
public void PostAnnouncement([FromBody] dynamic announcement) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; DbContextTransaction transaction = db.Database.BeginTransaction(); if (announcement != null) //if object not null { try { Announcement dynamicAnnouncement = new Announcement(); //create new announcement based on Object received ////dynamicAnnouncement.AnnouncementDate = DateTime.Today; dynamicAnnouncement.AnnouncementSenderID = announcement.PersonID; dynamicAnnouncement.AnnouncementDetail = announcement.AnnouncementDetail; dynamicAnnouncement.AnnouncementDate = DateTime.Today.ToString("yyyy-MM-dd"); db.Announcements.Add(dynamicAnnouncement); // add Announcement to database db.SaveChanges(); //save string d = announcement.AnnouncementDetail; //write new announcement detail to string Announcement created = db.Announcements.Where(x => x.AnnouncementDetail == d).FirstOrDefault(); //retrieve created announcement foreach (dynamic p in announcement.SelectedReceivers)// foreach person in receiver list { //create new Person_Announcement entry Person_Announcement dynamicPerson_Announcement = new Person_Announcement(); dynamicPerson_Announcement.PersonID = p.PersonID; dynamicPerson_Announcement.AnnouncementID = created.AnnouncementID; db.Person_Announcement.Add(dynamicPerson_Announcement);// Add to data base } int id = db.Announcements.OrderByDescending(x => x.AnnouncementID).Select(x => x.AnnouncementID).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = announcement.PersonID; auditLog.EventDescription = "Posted announcement with ID: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges();//save transaction.Commit(); } catch (Exception e) { transaction.Rollback(); dynamic toReturn = new ExpandoObject(); toReturn = e.Message + e.InnerException;// else error } } }
public List<dynamic> AssignLeader([FromBody] dynamic assignLeader) { if (assignLeader != null) { //Database connection ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //Configure proxy to eliminate overload of data db.Configuration.ProxyCreationEnabled = false; int id = assignLeader.form.PersonToAssign; int leader = assignLeader.form.PersonID; Person PersonAssignleader = db.People.Where(z => z.PersonID == id).FirstOrDefault(); try { PersonAssignleader.AssignLeader = assignLeader.form.PersonID; //db.SaveChanges(); toMember = PersonAssignleader.Email; toName = PersonAssignleader.Name; db.SaveChanges(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = assignLeader.PersonID; auditLog.EventDescription = "Leader Assigned with ID: " + leader + " to Person with ID: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); //Save nchanges and Add new position Person PersonLeaderAssigned = db.People.Where(x => x.AssignLeader == leader).FirstOrDefault(); string position = PersonLeaderAssigned.AssignLeader.ToString(); message = position + "have been assigned to " + id; Emailsubject = "Organisational Structure Position Assigned"; //sendEmail(); } catch (Exception) { } return UnassignedMemberList(db.People.Where(z => z.PersonID == id).ToList()); // return called method } else { return null; } }
public dynamic addDiscipleship([FromBody] dynamic discipleship) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; dynamic toReturn = new ExpandoObject(); string d = discipleship.DiscipleshipDescription; DbContextTransaction transaction = db.Database.BeginTransaction(); try { //retrieve similar data List <Discipleship> disc = db.Discipleships.Where(x => x.DiscipleshipDescription == d).ToList(); if (disc.Count == 0) { Discipleship thisDiscipleship = new Discipleship(); thisDiscipleship.DiscipleshipDescription = discipleship.DiscipleshipDescription; //If no similar entry exists add to db db.Discipleships.Add(thisDiscipleship); db.SaveChanges(); Discipleship NewDisc = db.Discipleships.Where(x => x.DiscipleshipDescription == thisDiscipleship.DiscipleshipDescription).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = discipleship.PersonID; auditLog.EventDescription = "Added a Discipleship with ID: " + NewDisc.DiscipleshipID + " and Name: " + NewDisc.DiscipleshipDescription; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges();//save transaction.Commit(); } else { //else return error toReturn.Error = "Similar already exists"; return(toReturn); } } catch (Exception e) { transaction.Rollback(); // if error occurs return error toReturn.Error = e.Message + e.InnerException; return(toReturn); } return(getAllDiscipleships()); }
public dynamic addOrgIndivPos([FromBody] dynamic OrgIndivPos) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; DbContextTransaction transaction = db.Database.BeginTransaction(); //If no data is received return error dynamic toReturn = new ExpandoObject(); if (OrgIndivPos == null) { toReturn.Error = "Cant be null"; return(toReturn); } try { Organisational_Individual_Position o = new Organisational_Individual_Position(); o.Decription = OrgIndivPos.form.Description; foreach (var goal in OrgIndivPos.form.Goal_Access) { int Goalid = goal.GoalAccessID; Goal_Access Igoal = db.Goal_Access.Where(x => x.GoalAccessID == Goalid).FirstOrDefault(); o.Goal_Access.Add(Igoal); } foreach (var uc in OrgIndivPos.form.Use_Cases) { int UCid = uc.UCID; Use_Cases Iuc = db.Use_Cases.Where(x => x.UCID == UCid).FirstOrDefault(); o.Use_Cases.Add(Iuc); } db.Organisational_Individual_Position.Add(o); db.SaveChanges(); int id = db.Organisational_Individual_Position.OrderByDescending(x => x.OrgIndivPosID).Select(x => x.OrgIndivPosID).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = OrgIndivPos.PersonID; auditLog.EventDescription = "Added Organisational Individual Position with ID:" + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); //save changes transaction.Commit(); return(getAllOrgIndivPos()); } catch (Exception e) { transaction.Rollback(); //if any errors occur return error message toReturn.Error = e.Message + e.InnerException; return(toReturn); } }
public dynamic updateOrgIndivPos([FromBody] dynamic currentOrgIndivPos) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; try { int id = currentOrgIndivPos.form.OrgIndivPosID; //retrieve existing object Organisational_Individual_Position thisOrgIndivPos = db.Organisational_Individual_Position.Include("Use_Cases").Include("Goal_Access").Where(i => i.OrgIndivPosID == id).FirstOrDefault(); //remove current Usecase and Goal access foreach (Goal_Access goal in thisOrgIndivPos.Goal_Access.ToList()) { thisOrgIndivPos.Goal_Access.Remove(goal); } foreach (Use_Cases uc in thisOrgIndivPos.Use_Cases.ToList()) { thisOrgIndivPos.Use_Cases.Remove(uc); } //assign new access foreach (var goal in currentOrgIndivPos.form.Goal_Access) { int Goalid = goal.GoalAccessID; Goal_Access Igoal = db.Goal_Access.Where(x => x.GoalAccessID == Goalid).FirstOrDefault(); thisOrgIndivPos.Goal_Access.Add(Igoal); } foreach (var uc in currentOrgIndivPos.form.Use_Cases) { int UCid = uc.UCID; Use_Cases Iuc = db.Use_Cases.Where(x => x.UCID == UCid).FirstOrDefault(); thisOrgIndivPos.Use_Cases.Add(Iuc); } Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = currentOrgIndivPos.PersonID; auditLog.EventDescription = "Updated an Organisational Individual Positions Access levels with ID: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); //save return(getAllOrgIndivPos()); //retrieve all } catch (Exception e) { //else return error dynamic toReturn = new ExpandoObject(); toReturn.Error = e.Message + e.InnerException; return(toReturn); } }
public List <dynamic> signOutChild([FromBody] dynamic confirmationSignOut) { //Validate for null values if (confirmationSignOut != null) { //Database connection ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //Configure proxy to eliminate overload of data db.Configuration.ProxyCreationEnabled = false; try { foreach (var child in confirmationSignOut.child) { int id = child; Person_Children childSignOut = db.Person_Children.Include(z => z.Child).Include(x => x.Person).Where(x => x.ChildID == id).FirstOrDefault(); childSignOut.KCVolunteerConfirmation = true; childSignOut.CheckIn = false; childSignOut.SignOut = true; childSignOut.SignOutDateTime = DateTime.Now; Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = confirmationSignOut.PersonID; auditLog.EventDescription = "Sign out child with ID: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); childrenList += childSignOut.Child.Name + " " + childSignOut.Child.Surname + ", "; toName = childSignOut.Person.Name; toMember = childSignOut.Person.Email; } message = childrenList + " Has been successfully signed-out of Kids Church at Christian Revival Church (CRC) Main."; Emailsubject = "Kids Church Sign-out @ CRC"; sendEmail(); foreach (var child in confirmationSignOut.child) { signOutRequestList.Remove(child); } return(getChildConfirmation(signOutRequestList)); } catch (Exception) { return(null); } } else { return(null); } }
public dynamic updateDiscipleship([FromBody] dynamic currentDiscipleship) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; string d = currentDiscipleship.DiscipleshipDescription; int id = currentDiscipleship.DiscipleshipID; //retrieve selected object Discipleship thisDiscipleship = db.Discipleships.Where(i => i.DiscipleshipID == id).FirstOrDefault(); //alter attributes thisDiscipleship.DiscipleshipID = currentDiscipleship.DiscipleshipID; thisDiscipleship.DiscipleshipDescription = currentDiscipleship.DiscipleshipDescription; dynamic toReturn = new ExpandoObject(); try { //check for similar List <Discipleship> disc = db.Discipleships.Where(x => x.DiscipleshipDescription == d).ToList(); if (disc.Count == 0) { Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = currentDiscipleship.PersonID; auditLog.EventDescription = "Updated a Discipleship with ID: " + thisDiscipleship.DiscipleshipID + " to have Name: " + thisDiscipleship.DiscipleshipDescription; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); //if not similar save db.SaveChanges(); return(getAllDiscipleships()); } else { //else return error toReturn.Error = "Similar already exists"; return(toReturn); } } catch (Exception e) { //else error toReturn.Error = e.Message + e.InnerException; return(toReturn); } }
public IHttpActionResult updateActivation([FromBody] dynamic currentPerson) { //Database connection ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; //Person thisPerson = db.People.Where(z => z.PersonID == currentPerson.PersonID).FirstOrDefault(); //Find the person current activation status id en updated the activation status id to inactive / active. if (currentPerson == null) { return(BadRequest(ModelState)); } try { int id = currentPerson.form.PersonID; Person psn = new Person(); psn = db.People.Where(x => x.PersonID == id).FirstOrDefault(); if (psn != null && psn.Activation_Status_ID == 2) { psn.Activation_Status_ID = 1; } else if (psn != null && psn.Activation_Status_ID == 1) { psn.Activation_Status_ID = 2; } Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = currentPerson.PersonID; auditLog.EventDescription = "Updated Member with ID: " + psn.PersonID + " to activation status " + psn.Activation_Status_ID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); } catch (Exception e) { dynamic toReturn = new ExpandoObject(); toReturn.Error = e; return(toReturn); } return(Ok(currentPerson)); }
public void ReportZoneHC([FromBody] dynamic AddZHA) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); DbContextTransaction transaction = db.Database.BeginTransaction(); try { if (AddZHA != null) { db.Configuration.ProxyCreationEnabled = false; Zone_Homecell_Attendance_Feedback za = new Zone_Homecell_Attendance_Feedback(); za.Date = AddZHA.Date; za.Description = AddZHA.Description; za.FirstTimeVisitors = AddZHA.FirstTimeVisitors; za.Leader = AddZHA.Leader; za.Member = AddZHA.Member; za.OrgIndivPosID = AddZHA.OrgIndivPosID; za.Salvations = AddZHA.Salvations; za.Visitors = AddZHA.Visitors; za.ZoneHomecellAttGoalID = AddZHA.ZoneHomecellAttGoalID; db.Zone_Homecell_Attendance_Feedback.Add(za); db.SaveChanges(); Zone_Homecell_Attendance_Feedback hc = db.Zone_Homecell_Attendance_Feedback.OrderByDescending(x => x.ZoneHomecellAttFeedbackID) .Select(x => x).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = AddZHA.PersonID; auditLog.EventDescription = "Feedback on Zone Homecell Attendance with ID: " + hc.ZoneHomecellAttFeedbackID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); transaction.Commit(); } } catch (Exception e) { transaction.Rollback(); } }
public void ReportChurchAttendance([FromBody] dynamic AddChurchAttendance) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); DbContextTransaction transaction = db.Database.BeginTransaction(); try { if (AddChurchAttendance != null) { db.Configuration.ProxyCreationEnabled = false; Church_Attendance_Feedback Att = new Church_Attendance_Feedback(); Att.Date = AddChurchAttendance.Date; Att.Description = AddChurchAttendance.Description; Att.Member = AddChurchAttendance.Member; Att.Salvations = AddChurchAttendance.Salvations; Att.Leader = AddChurchAttendance.Leader; Att.Visitors = AddChurchAttendance.Visitors; Att.FirstTimeVisitors = AddChurchAttendance.FirstTimeVisitors; Att.ChurchAttGoalID = AddChurchAttendance.ChurchAttGoalID; Att.OrgIndivPosID = AddChurchAttendance.OrgIndivPosID; db.Church_Attendance_Feedback.Add(Att); db.SaveChanges(); Church_Attendance_Feedback hc = db.Church_Attendance_Feedback.OrderByDescending(x => x.ChurchAttFeedbackID).Select(x => x).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = AddChurchAttendance.PersonID; auditLog.EventDescription = "Feedback on Church Attendance with ID: " + hc.ChurchAttFeedbackID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); transaction.Commit(); } } catch (Exception e) { transaction.Rollback(); } }
public void ReportDisc([FromBody] dynamic AddDisc) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); DbContextTransaction transaction = db.Database.BeginTransaction(); try { if (AddDisc != null) { db.Configuration.ProxyCreationEnabled = false; Discipleship_Feedback newDiscFeedback = new Discipleship_Feedback(); newDiscFeedback.Attendance = AddDisc.Attendance; newDiscFeedback.Date = AddDisc.Date; newDiscFeedback.Description = AddDisc.Description; newDiscFeedback.DiscipleshipGoalID = AddDisc.DiscipleshipGoalID; newDiscFeedback.DiscipleshipType = AddDisc.DiscipleshipType; newDiscFeedback.OrgIndivPosID = AddDisc.OrgIndivPosID; db.Discipleship_Feedback.Add(newDiscFeedback); db.SaveChanges(); Discipleship_Feedback hc = db.Discipleship_Feedback.OrderByDescending(x => x.DiscipleshipFeedbackID).Select(x => x).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = AddDisc.PersonID; auditLog.EventDescription = "Feedback on Discipleship with ID: " + hc.DiscipleshipFeedbackID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); transaction.Commit(); } } catch (Exception e) { transaction.Rollback(); } }
public void ReportZoneGrowth([FromBody] dynamic AddZG) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); DbContextTransaction transaction = db.Database.BeginTransaction(); try { if (AddZG != null) { db.Configuration.ProxyCreationEnabled = false; Zone_Growth_Feedback zg = new Zone_Growth_Feedback(); zg.Date = AddZG.Date; zg.Description = AddZG.Description; zg.Members = AddZG.Member; zg.OrgIndivPosID = AddZG.OrgIndivPosID; zg.ZonegrowthGoalID = AddZG.ZoneGrowthGoalID; db.Zone_Growth_Feedback.Add(zg); db.SaveChanges(); Zone_Growth_Feedback hc = db.Zone_Growth_Feedback.OrderByDescending(x => x.ZonegrowthFeedbackID).Select(x => x).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = AddZG.PersonID; auditLog.EventDescription = "Feedback on Zone Growth with ID: " + hc.ZonegrowthFeedbackID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); transaction.Commit(); } } catch (Exception e) { transaction.Rollback(); } }
public dynamic AddHomecellNotes(dynamic HomecellNotesName) //get string parameter { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //establish database connection db.Configuration.ProxyCreationEnabled = false; //configure proxy to eliminate overload of data dynamic returnMessage = new ExpandoObject(); string file = HomecellNotesName.FileName; //check if notes where already added Homecell_Notes checkNotes = db.Homecell_Notes.Where(z => z.HomecellNotes == file).FirstOrDefault(); Homecell_Notes newHomecellNotes = new Homecell_Notes(); //create object of type Homecell_Notes to add to the database if (checkNotes == null) //check to see if notes already exist in the databse { newHomecellNotes.UploadDate = DateTime.Today; newHomecellNotes.HomecellNotes = file; db.Homecell_Notes.Add(newHomecellNotes); db.SaveChanges(); //retrieve Homecell notes to remove based on selected Homecell notes Homecell_Notes HCNotes = db.Homecell_Notes.Where(z => z.HomecellNotes == file).FirstOrDefault(); //Add to Audit trail entity Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = HomecellNotesName.PersonID; auditLog.EventDescription = "Added Homecell Notes with with ID: " + HCNotes.HCNID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); returnMessage = "Successfull"; } else //if it exist an error message is returned. { returnMessage = "The file you are trying to upload, has already been uploaded. Please try again by uploading a different file."; } return(returnMessage); //return message to Angular }
public void ReportStructureGrowth([FromBody] dynamic AddStructureGrowth) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); DbContextTransaction transaction = db.Database.BeginTransaction(); try { if (AddStructureGrowth != null) { db.Configuration.ProxyCreationEnabled = false; Structure_Growth_Feedback sg = new Structure_Growth_Feedback(); sg.Date = AddStructureGrowth.form.Date; sg.Members = AddStructureGrowth.form.Member; sg.OrgIndivPosID = AddStructureGrowth.form.OrgIndivPosID; sg.StructureGrowthGoalID = AddStructureGrowth.form.StructureGrowthGoalID; sg.StructureName = AddStructureGrowth.form.StructureName; db.Structure_Growth_Feedback.Add(sg); db.SaveChanges(); Structure_Growth_Feedback hc = db.Structure_Growth_Feedback.OrderByDescending(x => x.StructureGrowthFeedbackID).Select(x => x).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = AddStructureGrowth.Person.PersonID; auditLog.EventDescription = "Feedback on Structure Growth with ID: " + hc.StructureGrowthFeedbackID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); transaction.Commit(); } } catch (Exception e) { transaction.Rollback(); } }
public void ReportNMO([FromBody] dynamic AddNMO) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); DbContextTransaction transaction = db.Database.BeginTransaction(); try { if (AddNMO != null) { db.Configuration.ProxyCreationEnabled = false; NMO_Feedback nmo = new NMO_Feedback(); nmo.Date = AddNMO.form.Date; nmo.MonthTotal = AddNMO.form.MonthTotal; nmo.NMOGoalID = AddNMO.form.NMOGoalID; nmo.OrgIndivPosID = AddNMO.form.OrgIndivPosID; db.NMO_Feedback.Add(nmo); db.SaveChanges(); NMO_Feedback hc = db.NMO_Feedback.OrderByDescending(x => x.NMOFeedbackID).Select(x => x).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = AddNMO.Person.PersonID; auditLog.EventDescription = "Feedback on New Members Orienatation with ID: " + hc.NMOFeedbackID; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); transaction.Commit(); } } catch (Exception e) { transaction.Rollback(); } }
public List<dynamic> updateMemberApproval([FromBody] dynamic currentPerson) { //Database connection ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //Configure proxy to eliminate overload of data db.Configuration.ProxyCreationEnabled = false; //Person thisPerson = db.People.Where(z => z.PersonID == currentPerson.PersonID).FirstOrDefault(); //Find the person current activation status id en updated the activation status id to approved. if (currentPerson != null) { try { int id = currentPerson.MemberID.PersonID; Person psn = db.People.Where(z => z.PersonID == id).FirstOrDefault(); //psn = db.People.Find(currentPerson.PersonID); if (psn.Activation_Status_ID == 4) { psn.Activation_Status_ID = 1; db.SaveChanges(); //string n = currentPerson.Name; //string s = currentPerson.Surname; //DateTime dob = currentPerson.DateOfBirth; //string num = currentPerson.Number; //string email = currentPerson.Email; //Person newNMO = db.People.Where(z => z.Name == n && z.Surname == s && z.DateOfBirth == dob && z.Number == num && z.Email == email).FirstOrDefault(); NMO_Follow_Up dynamicNMOFollowUP = new NMO_Follow_Up(); //dynamicNMOFollowUP.PersonID = db.People.OrderByDescending(z => z.PersonID).Select(z => z.PersonID).FirstOrDefault(); dynamicNMOFollowUP.PersonID = id; dynamicNMOFollowUP.FollowUpStatus = false; dynamicNMOFollowUP.NoAnswer = false; db.NMO_Follow_Up.Add(dynamicNMOFollowUP); db.SaveChanges(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = currentPerson.PersonID; auditLog.EventDescription = "Approved Member with ID: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); message = "You have been approved. You may now Log into Revive Communications using your username and password."; Emailsubject = "Member Approval at Christian Revival Church (CRC) Main"; toMember = psn.Email; toName = psn.Name; } } catch (Exception) { return null; } return getAllUnapprovedMembers(); } else { return null; } }
public dynamic updateOrgGroup(dynamic currentGroup) { //Database connection ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); //Configure proxy to eliminate overload of data db.Configuration.ProxyCreationEnabled = false; dynamic returnMessage = new ExpandoObject(); int id = currentGroup.GroupID.OrgGroupID; //Check to see if the child exists if (currentGroup != null) { if (currentGroup.GroupID.GroupTypeID == null || currentGroup.GroupID.Description == "" || currentGroup.GroupID.Address == "" || currentGroup.GroupID.SuburbID == null || currentGroup.GroupID.Size == null) { return(returnMessage.Message = "Please make sure that all information is provided for the group."); } else { //Retrieve selected object Organisational_Group thisGroup = db.Organisational_Group.Where(z => z.OrgGroupID == id).FirstOrDefault(); //Create dynamic object dynamic toReturn = new ExpandoObject(); try { //Update the attributes thisGroup.GroupTypeID = currentGroup.GroupTypeID; thisGroup.Description = currentGroup.GroupID.Description; thisGroup.Address = currentGroup.GroupID.Address; thisGroup.SuburbID = currentGroup.GroupID.SuburbID; thisGroup.Size = currentGroup.GroupID.Size; db.SaveChanges(); //Add to Audit trail entity Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = currentGroup.PersonID; auditLog.EventDescription = "Organisational Group updated with id: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges(); return(returnMessage.Message = "All done! We have received the group information."); } catch (Exception) { returnMessage.Message = "Something went wrong! Please try again."; return(returnMessage); } } } else { return(null); } }
public void SendInvitation([FromBody] dynamic inv) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; DbContextTransaction transaction = db.Database.BeginTransaction(); if (inv != null) //if object not null { try { Invitation dynamicInvitation = new Invitation(); //create new announcement based on Object received dynamicInvitation.InvitationDate = inv.InvitationDate.ToString("yyyy-mm-dd"); dynamicInvitation.InvitationSenderPersonID = inv.PersonID; dynamicInvitation.InvitationDetail = inv.InvitationDetail; dynamicInvitation.StartTime = inv.StartTime.ToString("HH:mm"); dynamicInvitation.EndTime = inv.EndTime.ToString("HH:mm"); dynamicInvitation.Summary = inv.Summary; db.Invitations.Add(dynamicInvitation); // add Invite to database db.SaveChanges(); //save string d = inv.InvitationDetail; //write new Invite detail to string Invitation created = db.Invitations.Where(x => x.InvitationDetail == d).FirstOrDefault(); //retrieve created Invite foreach (dynamic p in inv.SelectedReceivers)// foreach person in receiver list { //create new Person_Announcement entry Person_Invitation person_Invitation = new Person_Invitation(); person_Invitation.PersonID = p.PersonID; person_Invitation.InvitationID = created.InvitationID; db.Person_Invitation.Add(person_Invitation);// Add to data base db.SaveChanges(); } int id = db.Invitations.OrderByDescending(x => x.InvitationID).Select(x => x.InvitationID).FirstOrDefault(); Audit_Trail auditLog = new Audit_Trail(); auditLog.PersonID = inv.PersonID; auditLog.EventDescription = "Sent invitation with ID: " + id; auditLog.EventDateTime = DateTime.Now; db.Audit_Trail.Add(auditLog); db.SaveChanges();//save transaction.Commit(); } catch (Exception e) { transaction.Rollback(); dynamic toReturn = new ExpandoObject(); toReturn = e.Message + e.InnerException;// else error } } }