public override void Update(ISchedulerInfo shedulerInfo, Appointment appointmentToUpdate) { if (!PersistChanges) { return; } using (DbConnection conn = OpenConnection()) { using (DbTransaction tran = conn.BeginTransaction()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; cmd.Transaction = tran; PopulateAppointmentParameters(cmd, appointmentToUpdate); cmd.Parameters.Add(CreateParameter("@ClassID", appointmentToUpdate.ID)); cmd.CommandText = "UPDATE [DbProvider_Classes] SET [Subject] = @Subject, [Start] = @Start, [End] = @End,[Test]=@Test,[TeacherID] = @TeacherID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID WHERE [ClassID] = @ClassID"; cmd.ExecuteNonQuery(); ClearClassStudents(appointmentToUpdate.ID, cmd); FillClassStudents(appointmentToUpdate, cmd, appointmentToUpdate.ID); tran.Commit(); } } }
public override void Delete(ISchedulerInfo shedulerInfo, Appointment appointmentToDelete) { if (!PersistChanges) { return; } using (DbConnection conn = OpenConnection()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; using (DbTransaction tran = conn.BeginTransaction()) { cmd.Transaction = tran; ClearClassStudents(appointmentToDelete.ID, cmd); cmd.Parameters.Clear(); cmd.Parameters.Add(CreateParameter("@ClassID", appointmentToDelete.ID)); cmd.CommandText = "DELETE FROM [DbProvider_Classes] WHERE [ClassID] = @ClassID"; cmd.ExecuteNonQuery(); tran.Commit(); } } }
public void InsertVolunteerAvailability(ISchedulerInfo shedulerInfo, Appointment appointmentToInsert, sp_Availablity_DM cAvail) { using (VolTeerEntities context = new VolTeerEntities()) { try { var cVolAvail = new tblAvailability { VolID = cAvail.VolID, AddrID = cAvail.AddrID, AvailStart = appointmentToInsert.Start, AvailEnd = appointmentToInsert.End, Description = appointmentToInsert.Description, RecurrenceParentID = (int?)(appointmentToInsert.RecurrenceParentID), RecurrenceRule = appointmentToInsert.RecurrenceRule, Subject = appointmentToInsert.Subject }; context.tblAvailabilities.Add(cVolAvail); context.SaveChanges(); } catch (Exception ex) { } } }
public override void Delete(ISchedulerInfo shedulerInfo, Appointment appointmentToDelete) { if (!PersistChanges) { return; } using (DbConnection conn = OpenConnection()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; using (DbTransaction tran = conn.BeginTransaction()) { cmd.Transaction = tran; ClearClassStudents(appointmentToDelete.ID, cmd); cmd.Parameters.Clear(); cmd.Parameters.Add(CreateParameter("@ClassID", appointmentToDelete.ID)); cmd.CommandText = "DELETE FROM [DbProvider_Classes] WHERE [ClassID] = @ClassID"; cmd.ExecuteNonQuery(); tran.Commit(); } } }
public override IEnumerable<Appointment> GetAppointments(ISchedulerInfo shedulerInfo) { string strVolID = "6CD40064-CF05-4B55-93C0-6E4D7F9CCE34"; Guid VolID = new Guid(strVolID); int AddrID = 1; return DAL.ListVolunteerAvailability(VolID, AddrID); }
public override IEnumerable <Appointment> GetAppointments(ISchedulerInfo shedulerInfo) { var myInfo = shedulerInfo as MySchedulerInfo; string teacherID = myInfo.TeacherID; List <Appointment> appointments = new List <Appointment>(); using (DbConnection conn = OpenConnection()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT [ClassID], [Subject], [Start], [End], [RecurrenceRule], [RecurrenceParentId], [Reminder], [Test] FROM [DbProvider_Classes]"; if (teacherID != "all") { cmd.CommandText += "WHERE TeacherID = " + teacherID; } using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Appointment apt = new Appointment(); apt.ID = reader["ClassID"]; apt.Subject = Convert.ToString(reader["Subject"]); apt.Start = DateTime.SpecifyKind(Convert.ToDateTime(reader["Start"]), DateTimeKind.Utc); apt.End = DateTime.SpecifyKind(Convert.ToDateTime(reader["End"]), DateTimeKind.Utc); apt.RecurrenceRule = Convert.ToString(reader["RecurrenceRule"]); apt.RecurrenceParentID = reader["RecurrenceParentId"] == DBNull.Value ? null : reader["RecurrenceParentId"]; apt.Attributes["Test"] = Convert.ToString(reader["Test"]); if (reader["Reminder"] != DBNull.Value) { IList <Reminder> reminders = Reminder.TryParse(Convert.ToString(reader["Reminder"])); if (reminders != null) { apt.Reminders.AddRange(reminders); } } if (apt.RecurrenceParentID != null) { apt.RecurrenceState = RecurrenceState.Exception; } else if (apt.RecurrenceRule != string.Empty) { apt.RecurrenceState = RecurrenceState.Master; } LoadResources(apt); appointments.Add(apt); } } } return(appointments); }
public override IDictionary <ResourceType, IEnumerable <Resource> > GetResources(ISchedulerInfo schedulerInfo) { Dictionary <ResourceType, IEnumerable <Resource> > resCollection = new Dictionary <ResourceType, IEnumerable <Resource> >(); resCollection.Add(new ResourceType("Teacher", false), Teachers.Values); resCollection.Add(new ResourceType("Student", true), Students.Values); return(resCollection); }
public override void Insert(ISchedulerInfo shedulerInfo, Appointment appointmentToInsert) { sp_Availablity_DM cAvail = new sp_Availablity_DM(); cAvail.VolID = new Guid(appointmentToInsert.Attributes["VolID"]); cAvail.AddrID = Convert.ToInt32(appointmentToInsert.Attributes["AddrID"]); DAL.InsertVolunteerAvailability(shedulerInfo, appointmentToInsert, cAvail); }
public override IEnumerable<Appointment> GetAppointments(ISchedulerInfo shedulerInfo) { var myInfo = shedulerInfo as MySchedulerInfo; string teacherID = myInfo.TeacherID; List<Appointment> appointments = new List<Appointment>(); using (DbConnection conn = OpenConnection()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT [ClassID], [Subject], [Start], [End], [RecurrenceRule], [RecurrenceParentId], [Reminder], [Test] FROM [DbProvider_Classes]"; if (teacherID != "all") cmd.CommandText += "WHERE TeacherID = " + teacherID; using (DbDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Appointment apt = new Appointment(); apt.ID = reader["ClassID"]; apt.Subject = Convert.ToString(reader["Subject"]); apt.Start = DateTime.SpecifyKind(Convert.ToDateTime(reader["Start"]), DateTimeKind.Utc); apt.End = DateTime.SpecifyKind(Convert.ToDateTime(reader["End"]), DateTimeKind.Utc); apt.RecurrenceRule = Convert.ToString(reader["RecurrenceRule"]); apt.RecurrenceParentID = reader["RecurrenceParentId"] == DBNull.Value ? null : reader["RecurrenceParentId"]; apt.Attributes["Test"] = Convert.ToString(reader["Test"]); if (reader["Reminder"] != DBNull.Value) { IList<Reminder> reminders = Reminder.TryParse(Convert.ToString(reader["Reminder"])); if (reminders != null) { apt.Reminders.AddRange(reminders); } } if (apt.RecurrenceParentID != null) { apt.RecurrenceState = RecurrenceState.Exception; } else if (apt.RecurrenceRule != string.Empty) { apt.RecurrenceState = RecurrenceState.Master; } LoadResources(apt); appointments.Add(apt); } } } return appointments; }
public void DeleteVolunteerAvailability(ISchedulerInfo shedulerInfo, Appointment appointmentToDelete, sp_Availablity_DM cAvail) { using (VolTeerEntities context = new VolTeerEntities()) { var cVolAvail = new tblAvailability { VolID = cAvail.VolID, AddrID = cAvail.AddrID, AvailID = cAvail.AvailID }; context.tblAvailabilities.Remove(cVolAvail); context.SaveChanges(); } }
public override void Delete(ISchedulerInfo shedulerInfo, Appointment appointmentToDelete) { if (!PersistChanges) { return; } sp_Availablity_DM cAvail = new sp_Availablity_DM(); cAvail.VolID = new Guid(appointmentToDelete.Attributes["VolID"]); cAvail.AddrID = Convert.ToInt32(appointmentToDelete.Attributes["AddrID"]); cAvail.AvailID = Convert.ToInt32(appointmentToDelete.Attributes["AvailID"]); DAL.DeleteVolunteerAvailability(shedulerInfo, appointmentToDelete, cAvail); }
public override void Insert(ISchedulerInfo shedulerInfo, Appointment appointmentToInsert) { if (!PersistChanges) { return; } using (DbConnection conn = OpenConnection()) { using (DbTransaction tran = conn.BeginTransaction()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; cmd.Transaction = tran; PopulateAppointmentParameters(cmd, appointmentToInsert); cmd.CommandText = @" INSERT INTO [DbProvider_Classes] ([Subject], [Start], [End], [TeacherID], [RecurrenceRule], [RecurrenceParentID], [Reminder],[Test]) VALUES (@Subject, @Start, @End, @TeacherID, @RecurrenceRule, @RecurrenceParentID, @Reminder, @Test)" ; if (DbFactory is SqlClientFactory) { cmd.CommandText += Environment.NewLine + "SELECT SCOPE_IDENTITY()"; } else { cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT @@IDENTITY"; } int identity = Convert.ToInt32(cmd.ExecuteScalar()); FillClassStudents(appointmentToInsert, cmd, identity); tran.Commit(); } } }
public override IEnumerable <Appointment> GetAppointments(ISchedulerInfo schedulerInfo) { var myInfo = schedulerInfo as MySchedulerInfo; if (myInfo != null && myInfo.CategoryNames != null) { var appointmentsList = base.GetAppointments(schedulerInfo); var appointmentsWithCalendarResource = appointmentsList.Where(a => a.Resources.GetResourceByType("Calendar") != null).Select(a => a); var predicate = PredicateBuilder.False <Appointment>(); foreach (string categoryName in myInfo.CategoryNames) { string temp = categoryName; predicate = predicate.Or(a => a.Resources.GetResourceByType("Calendar").Text == temp); } return(appointmentsWithCalendarResource.AsQueryable().Where(predicate).Select(a => a).AsEnumerable()); } else { return(base.GetAppointments(schedulerInfo)); } }
public MySchedulerInfo(ISchedulerInfo baseInfo, string teacherID) : base(baseInfo) { TeacherID = teacherID; }
public override void Update(ISchedulerInfo shedulerInfo, Appointment appointmentToUpdate) { if (!PersistChanges) { return; } using (DbConnection conn = OpenConnection()) { using (DbTransaction tran = conn.BeginTransaction()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; cmd.Transaction = tran; PopulateAppointmentParameters(cmd, appointmentToUpdate); cmd.Parameters.Add(CreateParameter("@ClassID", appointmentToUpdate.ID)); cmd.CommandText = "UPDATE [DbProvider_Classes] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [TeacherID] = @TeacherID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID WHERE [ClassID] = @ClassID"; cmd.ExecuteNonQuery(); ClearClassStudents(appointmentToUpdate.ID, cmd); FillClassStudents(appointmentToUpdate, cmd, appointmentToUpdate.ID); tran.Commit(); } } }
public override void Insert(ISchedulerInfo shedulerInfo, Appointment appointmentToInsert) { if (!PersistChanges) { return; } using (DbConnection conn = OpenConnection()) { using (DbTransaction tran = conn.BeginTransaction()) { DbCommand cmd = DbFactory.CreateCommand(); cmd.Connection = conn; cmd.Transaction = tran; PopulateAppointmentParameters(cmd, appointmentToInsert); cmd.CommandText = @" INSERT INTO [DbProvider_Classes] ([Subject], [Start], [End], [TeacherID], [RecurrenceRule], [RecurrenceParentID], [Reminder]) VALUES (@Subject, @Start, @End, @TeacherID, @RecurrenceRule, @RecurrenceParentID, @Reminder)"; if (DbFactory is SqlClientFactory) { cmd.CommandText += Environment.NewLine + "SELECT SCOPE_IDENTITY()"; } else { cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT @@IDENTITY"; } int identity = Convert.ToInt32(cmd.ExecuteScalar()); FillClassStudents(appointmentToInsert, cmd, identity); tran.Commit(); } } }
public override IDictionary<ResourceType, IEnumerable<Resource>> GetResources(ISchedulerInfo schedulerInfo) { Dictionary<ResourceType, IEnumerable<Resource>> resCollection = new Dictionary<ResourceType, IEnumerable<Resource>>(); resCollection.Add(new ResourceType("Teacher", false), Teachers.Values); resCollection.Add(new ResourceType("Student", true), Students.Values); return resCollection; }
public MySchedulerInfo(ISchedulerInfo baseInfo, DateTime visibleRangeStart, DateTime visibleRangeEnd) : base(baseInfo) { VisibleRangeStart = visibleRangeStart; VisibleRangeEnd = visibleRangeEnd; }
public MySchedulerInfo(ISchedulerInfo baseInfo, string[] categoryNames) : base(baseInfo) { CategoryNames = categoryNames; }
public override IDictionary<ResourceType, IEnumerable<Resource>> GetResources(ISchedulerInfo schedulerInfo) { var dict = new Dictionary<ResourceType, IEnumerable<Resource>>() { { new ResourceType("Type"), _types }, { new ResourceType("User"), GetAllEmployees() } }; return dict; }
public override IDictionary <ResourceType, IEnumerable <Resource> > GetResources(ISchedulerInfo schedulerInfo) { return(null); }
public void UpdateVolunteerAvailability(ISchedulerInfo shedulerInfo, Appointment appointmentToUpdate, sp_Availablity_DM cAvail) { using (VolTeerEntities context = new VolTeerEntities()) { var cVolAvail = new tblAvailability { VolID = cAvail.VolID, AddrID = cAvail.AddrID, AvailID = cAvail.AvailID, AvailStart = appointmentToUpdate.Start, AvailEnd = appointmentToUpdate.End, Description = appointmentToUpdate.Description, RecurrenceParentID = (int?)(appointmentToUpdate.RecurrenceParentID), RecurrenceRule = appointmentToUpdate.RecurrenceRule, Subject = appointmentToUpdate.Subject }; context.SaveChanges(); } }
public override IDictionary<ResourceType, IEnumerable<Resource>> GetResources(ISchedulerInfo schedulerInfo) { Dictionary<ResourceType, IEnumerable<Resource>> resCollection = new Dictionary<ResourceType, IEnumerable<Resource>>(); return resCollection; }
public MySchedulerInfo(ISchedulerInfo baseInfo, string teacherID) : base(baseInfo) { TeacherID = teacherID; }
public MySchedulerInfo(ISchedulerInfo baseInfo, string[] categoryNames) : base(baseInfo) { CategoryNames = categoryNames; }