public void InsertTa(Ta ta, ref List<string> errors) { if (ta == null) { errors.Add("Ta cannot be null"); throw new ArgumentException(); } if (string.IsNullOrEmpty(ta.FirstName)) { errors.Add("Ta first name cannot be null"); throw new ArgumentException(); } if (string.IsNullOrEmpty(ta.LastName)) { errors.Add("Ta last name cannot be null"); throw new ArgumentException(); } if (this.repository.IsNotDuplicateTa(ta, ref errors)) { this.repository.AddTa(ta, ref errors); } else { errors.Add("Duplicate Ta"); } }
public void UpdateAdmin(Admin adminPoco, ref List<string> errors) { if (adminPoco == null) { errors.Add("Admin cannot be null"); throw new ArgumentException(); } if (string.IsNullOrEmpty(adminPoco.FirstName)) { errors.Add("Admin first name cannot be null"); throw new ArgumentException(); } if (string.IsNullOrEmpty(adminPoco.LastName)) { errors.Add("Admin last name cannot be null"); throw new ArgumentException(); } if (adminPoco.Id <= 0) { errors.Add("Admin Id cannot be null"); throw new ArgumentException(); } this.repository.UpdateAdmin(adminPoco, ref errors); }
public float CalculateGpa(string studentId, List<Enrollment> enrollments, ref List<string> errors) { if (string.IsNullOrEmpty(studentId)) { errors.Add("Invalid student id"); throw new ArgumentException(); } if (enrollments == null) { errors.Add("Invalid student id"); throw new ArgumentException(); } if (enrollments.Count == 0) { return 0.0f; } var sum = 0.0f; foreach (var enrollment in enrollments) { sum += enrollment.GradeValue; } return sum / enrollments.Count; }
public void InsertInstructor(Instructor instructor, ref List<string> errors) { if (instructor == null) { errors.Add("Instructor cannot be null"); throw new ArgumentException(); } if (string.IsNullOrEmpty(instructor.InstructorId)) { errors.Add("Invalid Instructor id"); throw new ArgumentException(); } if(string.IsNullOrEmpty(instructor.FirstName)) { errors.Add("Instructor requires a first name."); throw new ArgumentException(); } if (string.IsNullOrEmpty(instructor.LastName)) { errors.Add("Instructor requires a last name."); throw new ArgumentException(); } this.repository.InsertInstructor(instructor, ref errors); }
public void InsertAdmin(Admin admin, ref List<string> errors) { if (admin == null) { errors.Add("Instructor cannot be null"); throw new ArgumentException(); } if (string.IsNullOrEmpty(admin.FirstName)) { errors.Add("Admin requires a first name."); throw new ArgumentException(); } if (string.IsNullOrEmpty(admin.LastName)) { errors.Add("Admin requires a last name."); throw new ArgumentException(); } if (string.IsNullOrEmpty(admin.Email)) { errors.Add("Admin requires an email."); throw new ArgumentException(); } if (string.IsNullOrEmpty(admin.Password)) { errors.Add("Admin requires a password."); throw new ArgumentException(); } this.repository.InsertAdmin(admin, ref errors); }
/// <summary> /// Executes the service. /// </summary> public override void OnExecute() { List<OPoint> pointList = TablesLogic.tPoint.LoadList( TablesLogic.tPoint.ReadingDay == DateTime.Today.Day & TablesLogic.tPoint.IsActive == 1 & (TablesLogic.tPoint.LastReminderDate ==null | TablesLogic.tPoint.LastReminderDate.Date() < DateTime.Today.Date)); List<Guid> userIdList = new List<Guid>(); foreach (OPoint point in pointList) { if (point.ReminderUser1 != null) { if (!userIdList.Contains((Guid)point.ReminderUser1.ObjectID)) { userIdList.Add((Guid)point.ReminderUser1.ObjectID); SendEmail(point.ReminderUser1); } } if (point.ReminderUser2 != null) { if (!userIdList.Contains((Guid)point.ReminderUser2.ObjectID)) { userIdList.Add((Guid)point.ReminderUser2.ObjectID); SendEmail(point.ReminderUser2); } } if (point.ReminderUser3 != null) { if (!userIdList.Contains((Guid)point.ReminderUser3.ObjectID)) { userIdList.Add((Guid)point.ReminderUser3.ObjectID); SendEmail(point.ReminderUser3); } } if (point.ReminderUser4 != null) { if (!userIdList.Contains((Guid)point.ReminderUser4.ObjectID)) { userIdList.Add((Guid)point.ReminderUser4.ObjectID); SendEmail(point.ReminderUser4); } } using (Connection c = new Connection()) { point.LastReminderDate = DateTime.Today; point.Save(); c.Commit(); } } }
/// <summary> /// Executes the service. /// </summary> public override void OnExecute() { List<OContractReminder> reminders = TablesLogic.tContractReminder.LoadList( TablesLogic.tContractReminder.IsReminderSent != 1 & TablesLogic.tContractReminder.ReminderDate <= DateTime.Today.Date); List<Guid> userIdList = new List<Guid>(); foreach (OContractReminder re in reminders) { if (re.Contract.Reminder1User != null) { if (!userIdList.Contains((Guid)re.Contract.Reminder1UserID)) { userIdList.Add((Guid)re.Contract.Reminder1UserID); SendEmail(re, re.Contract.Reminder1User); } } if (re.Contract.Reminder2User != null) { if (!userIdList.Contains((Guid)re.Contract.Reminder2UserID)) { userIdList.Add((Guid)re.Contract.Reminder2UserID); SendEmail(re, re.Contract.Reminder2User); } } if (re.Contract.Reminder3User != null) { if (!userIdList.Contains((Guid)re.Contract.Reminder3UserID)) { userIdList.Add((Guid)re.Contract.Reminder3UserID); SendEmail(re, re.Contract.Reminder3User); } } if (re.Contract.Reminder4User != null) { if (!userIdList.Contains((Guid)re.Contract.Reminder4UserID)) { userIdList.Add((Guid)re.Contract.Reminder4UserID); SendEmail(re, re.Contract.Reminder4User); } } using (Connection c = new Connection()) { re.IsReminderSent = 1; re.Save(); c.Commit(); } } }
/// <summary> /// Executes the service. /// </summary> public override void OnExecute() { List<OEquipmentReminder> reminders = TablesLogic.tEquipmentReminder.LoadList( TablesLogic.tEquipmentReminder.IsReminderSent != 1 & TablesLogic.tEquipmentReminder.ReminderDate <= DateTime.Today.Date); List<Guid> userIdList = new List<Guid>(); foreach (OEquipmentReminder re in reminders) { if (re.Equipment.ReminderUser1 != null) { if (!userIdList.Contains((Guid)re.Equipment.ReminderUser1ID)) { userIdList.Add((Guid)re.Equipment.ReminderUser1ID); SendEmail(re, re.Equipment.ReminderUser1); } } if (re.Equipment.ReminderUser2 != null) { if (!userIdList.Contains((Guid)re.Equipment.ReminderUser2ID)) { userIdList.Add((Guid)re.Equipment.ReminderUser2ID); SendEmail(re, re.Equipment.ReminderUser2); } } if (re.Equipment.ReminderUser3 != null) { if (!userIdList.Contains((Guid)re.Equipment.ReminderUser3ID)) { userIdList.Add((Guid)re.Equipment.ReminderUser3ID); SendEmail(re, re.Equipment.ReminderUser3); } } if (re.Equipment.ReminderUser4 != null) { if (!userIdList.Contains((Guid)re.Equipment.ReminderUser4ID)) { userIdList.Add((Guid)re.Equipment.ReminderUser4ID); SendEmail(re, re.Equipment.ReminderUser4); } } using (Connection c = new Connection()) { re.IsReminderSent = 1; re.Save(); c.Commit(); } } }
public void AssignPreReq(int courseId, int preReqCourseId, ref List<string> errors) { if (courseId <= 0) { errors.Add("Invalid courseId"); throw new ArgumentException(); } if (preReqCourseId <= 0) { errors.Add("Invalid preReqCourseId"); throw new ArgumentException(); } this.repository.AssignPreReqToCourse(courseId, preReqCourseId, ref errors); }
public void InsertTA(TA ta, ref List<string> errors) { if (ta == null) { errors.Add("TA cannot be null"); throw new ArgumentException(); } if (string.IsNullOrEmpty(ta.TA_Id)) { errors.Add("Invalid TA id"); throw new ArgumentException(); } this.repository.InsertTA(ta, ref errors); }
public Enrollment GetEnrollmentDetail(string studentId, int scheduleId, ref List<string> errors) { if (string.IsNullOrEmpty(studentId)) { errors.Add("Invalid studentId"); throw new ArgumentException(); } if (scheduleId <= 0) { errors.Add("Invalid scheduleId"); throw new ArgumentException(); } return this.repository.GetEnrollmentDetail(studentId, scheduleId, ref errors); }
public float GetCourseRating(int course_id, ref List<string> errors) { var courseRating = 0; List<CapeReview> capeReviewList = new List<CapeReview>(); var reviewCount = 0; //// can never fail default to == 0 for all service layers if (string.IsNullOrEmpty(course_id.ToString())) { errors.Add("Invalid course id"); throw new ArgumentException(); } capeReviewList = this.repository.FindCapeReviewsByCourseId(course_id, ref errors); foreach (CapeReview cr in capeReviewList) { if (cr.CourseRating > 0) { reviewCount++; courseRating += cr.CourseRating; } } return courseRating / reviewCount; }
public void InsertStudent(Student student, ref List<string> errors) { if (student == null) { errors.Add("Student cannot be null"); throw new ArgumentException(); } if (student.StudentId.Length < 5) { errors.Add("Invalid student ID"); throw new ArgumentException(); } this.repository.InsertStudent(student, ref errors); }
public override List<Recipe> GetRecipes() { var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Model"].ToString()); connection.Open(); var command = new SqlCommand { Connection = connection, CommandText = "select * from recipedbs" }; var reader = command.ExecuteReader(); var recipes = new List<Recipe>(); while (reader.Read()) { recipes.Add( new Recipe { Id = Guid.Parse(reader["id"].ToString()), Title = (string)reader["name"] } ); } return recipes; }
public void DeleteTA(TA ta, ref List<string> errors) { if (string.IsNullOrEmpty(ta.TA_Id)) { errors.Add("Invalid TA id"); throw new ArgumentException(); } if (string.IsNullOrEmpty(ta.Schedule_Id)) { errors.Add("Invalid Schedule id"); throw new ArgumentException(); } this.repository.DeleteTA(ta, ref errors); }
public void ApproveGradeChange(GradeChange gc, ref List<string> errors) { if (gc.Course_id == -1) { errors.Add("Invalid course ID"); throw new ArgumentException(); } this.repository.ApproveGradeChange(gc.GradeChangeId, ref errors); if (errors.Count != 0) { errors.Add("Invalid schedule ID"); throw new ArgumentException(); } }
public List<Schedule> GetScheduleList(string year, string quarter, ref List<string> errors) { if (string.IsNullOrEmpty(year)) { errors.Add("Invalid year."); throw new ArgumentException(); } if (string.IsNullOrEmpty(quarter)) { errors.Add("Invalid quarter."); throw new ArgumentException(); } return this.repository.GetScheduleList(year, quarter, ref errors); }
public void InsertTaTutor(TaTutor ta_tutor, ref List<string> errors) { if (ta_tutor == null) { errors.Add("TA/Tutor cannot be null"); throw new ArgumentException(); } if (ta_tutor.TaTutorId.Length < 6 || ta_tutor.TaTutorId.Length > 11) { errors.Add("Invalid TA/Tutor ID"); throw new ArgumentException(); } if (!this.CheckId(ta_tutor.TaTutorId)) { errors.Add("Invalid TA/Tutor ID"); throw new ArgumentException(); } if (!this.CheckName(ta_tutor.FirstName)) { errors.Add("Invalid first name"); throw new ArgumentException(); } if (!this.CheckName(ta_tutor.LastName)) { errors.Add("Invalid last name"); throw new ArgumentException(); } if ((int)ta_tutor.TaType < 0 || (int)ta_tutor.TaType > 2) { errors.Add("Invalid ta/tutor type"); throw new ArgumentException(); } else if (!this.CheckType((int)ta_tutor.TaType)) { errors.Add("Invalid ta/tutor type"); throw new ArgumentException(); } this.repository.InsertTaTutor(ta_tutor, ref errors); }
public Instructor GetInstructorInfo(String id, ref List<string> errors) { if (string.IsNullOrEmpty(id)) { errors.Add("Instructor cannot be null."); throw new ArgumentException(); } return this.repository.GetInstructorInfo(id, ref errors); }
public List<CapeCourseReview> GetCapeReviewByCourse(string course_id, ref List<string> errors) { int cid; if (string.IsNullOrEmpty(course_id) || !int.TryParse(course_id, out cid)) { errors.Add("Invalid Course_ID"); throw new ArgumentException(); } if (cid < 0) { errors.Add("Invalid Course_ID"); throw new ArgumentException(); } return this.repository.GetCapeReviewByCourse(cid, ref errors); }
public Instructor GetInstructor(string instructor_id, ref List<string> errors) { if (string.IsNullOrEmpty(instructor_id)) { errors.Add("Invalid instructor_id"); throw new ArgumentException(); } return this.repository.FindInstructorById(int.Parse(instructor_id), ref errors); }
public Ta GetTaByName(string ta_name, ref List<string> errors) { if (string.IsNullOrEmpty(ta_name)) { errors.Add("Invalid ta_id"); throw new ArgumentException(); } return this.repository.FindTaByName(ta_name, ref errors); }
public void DeleteStudent(string id, ref List<string> errors) { if (string.IsNullOrEmpty(id)) { errors.Add("Invalid student id"); throw new ArgumentException(); } this.repository.DeleteStudent(id, ref errors); }
public void EnrollSchedule(string studentId, int scheduleId, ref List<string> errors) { if (string.IsNullOrEmpty(studentId) || scheduleId < 0) { errors.Add("Invalid student id or schedule id"); throw new ArgumentException(); } this.repository.EnrollSchedule(studentId, scheduleId, ref errors); }
public void DeleteInstructor(int instructor_id, ref List<string> errors) { if (instructor_id <= 0) { errors.Add("Invalid ta_id"); throw new ArgumentException(); } this.repository.RemoveInstructor(instructor_id, ref errors); }
public static List<Dto.TicketInformation> GetAllTicketInformation() { List<Dto.TicketInformation> tickets = new List<Dto.TicketInformation>(); foreach(Dmn.TicketInformation ticket in Dmn.DummyDatabase.TicketInformation) { tickets.Add(TicketInformationConverter.ToDto(ticket)); } return tickets; }
public static IList<ProductViewModel> ConvertToProductListViewModel( this IList<Model.Product> products) { IList<ProductViewModel> productViewModels = new List<ProductViewModel>(); foreach (Model.Product p in products) { productViewModels.Add(p.ConvertToProductViewModel()); } return productViewModels; }
public GradeChange FindGradeChangeByCourseId(int course_id, ref List<string> errors) { if (course_id <= 0) { errors.Add("Invalid course_id"); throw new ArgumentException(); } return this.repository.FindGradeChangeByCourseId(course_id, ref errors); }
public Admin GetAdminById(int adminId, ref List<string> errors) { if (adminId <= 0) { errors.Add("Invalid admin_id"); throw new ArgumentException(); } return this.repository.FindAdminById(adminId, ref errors); }
public GradeChange FindGradeChangeByStudentId(string student_id, ref List<string> errors) { if (string.IsNullOrEmpty(student_id)) { errors.Add("Invalid student_id"); throw new ArgumentException(); } return this.repository.FindGradeChangeByStudentId(student_id, ref errors); }