当前位置: 首页>>代码示例>>C#>>正文


C# List.Add方法代码示例

本文整理汇总了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");
            }
        }
开发者ID:fastily,项目名称:cse136,代码行数:29,代码来源:TaService.cs

示例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);
        }
开发者ID:fastily,项目名称:cse136,代码行数:28,代码来源:AdminService.cs

示例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;
        }
开发者ID:jmj010,项目名称:personal_projects,代码行数:28,代码来源:StudentService.cs

示例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);
        }
开发者ID:danielcristiancazares,项目名称:Course-Management-Site,代码行数:28,代码来源:InstructorService.cs

示例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);
        }
开发者ID:danielcristiancazares,项目名称:Course-Management-Site,代码行数:34,代码来源:AdminService.cs

示例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();
                }
            }
        }
开发者ID:vinhdoan,项目名称:Angroup.demo,代码行数:55,代码来源:ReminderForMeterReadingService.cs

示例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();
                }
            }

        }
开发者ID:vinhdoan,项目名称:Angroup.demo,代码行数:52,代码来源:ContractReminderService.cs

示例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();
                }
            }

        }
开发者ID:vinhdoan,项目名称:Angroup.demo,代码行数:52,代码来源:EquipmentReminderService.cs

示例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);
        }
开发者ID:fastily,项目名称:cse136,代码行数:16,代码来源:CourseService.cs

示例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);
        }
开发者ID:danielcristiancazares,项目名称:Course-Management-Site,代码行数:16,代码来源:TaService.cs

示例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);
        }
开发者ID:fastily,项目名称:cse136,代码行数:16,代码来源:EnrollmentService.cs

示例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;
        }
开发者ID:fastily,项目名称:cse136,代码行数:25,代码来源:CapeReviewService.cs

示例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);
        }
开发者ID:calmajos,项目名称:enterprise-web-app-136,代码行数:16,代码来源:StudentService.cs

示例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;
        }
开发者ID:NitriKx,项目名称:M2DL-ACEE-TPs-CSharp,代码行数:26,代码来源:AdoRecipeService.cs

示例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);
        }
开发者ID:danielcristiancazares,项目名称:Course-Management-Site,代码行数:16,代码来源:TaService.cs


注:本文中的Service.List.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。