예제 #1
0
        public static List<AddStudentSearchModel> AddStudentSearch(string lastName, int gradeLevelKey)
        {
            using (var db = new SWC_LMSEntities())
            {
                var results =
                    from l in db.LmsUsers
                    join g in db.GradeLevels
                        on l.GradeLevelId equals g.GradeLevelId
                    select new
                    {
                        l.FirstName,
                        l.LastName,
                        l.GradeLevelId,
                        g.GradeLevelName
                    };
                var modelList = new List<AddStudentSearchModel>();
                foreach (var x in results)
                {
                    var model = new AddStudentSearchModel
                    {
                        FirstName = x.FirstName,
                        LastName = x.LastName,
                        GradeLevelKey = Convert.ToInt32(x.GradeLevelId),
                        GradeLevelName = x.GradeLevelName
                    };
                    modelList.Add(model);
                }
                return modelList.Where(x => x.LastName.ToUpper().Contains(lastName.ToUpper()) ||
                                     x.GradeLevelKey == gradeLevelKey).ToList();

            }
        }
 public List<AddStudentSearchModel> Post(AddStudentSearchModel model)
 {
     var results = TeacherRepo.AddStudentSearch(model.LastName, model.GradeLevelKey);
     return results.Select(x => new AddStudentSearchModel()
     {
         FirstName = x.FirstName,
         LastName = x.LastName,
         GradeLevelKey = x.GradeLevelKey,
         GradeLevelName = x.GradeLevelName
     }).ToList();
 }