本文整理匯總了C#中Service.List.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# List.Add方法的具體用法?C# List.Add怎麽用?C# List.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Service.List
的用法示例。
在下文中一共展示了List.Add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: InsertTa
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");
}
}
示例2: UpdateAdmin
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);
}
示例3: CalculateGpa
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;
}
示例4: InsertInstructor
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);
}
示例5: InsertAdmin
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);
}
示例6: OnExecute
/// <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();
}
}
}
示例7: OnExecute
/// <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();
}
}
}
示例8: OnExecute
/// <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();
}
}
}
示例9: AssignPreReq
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);
}
示例10: InsertTA
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);
}
示例11: GetEnrollmentDetail
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);
}
示例12: GetCourseRating
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;
}
示例13: InsertStudent
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);
}
示例14: GetRecipes
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;
}
示例15: DeleteTA
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);
}