public async Task <object> Handle(CreateRegistration request, CancellationToken cancellationToken)
        {
            var _Student = new Models.Entity.Student
            {
                Name       = request.Name,
                FatherName = request.FatherName,
                GenderId   = request.GenderID,
                Nid        = request.Nid,
                Email      = request.Email,
                Phone      = request.Phone
            };
            await eMSContext.AddAsync(_Student);

            await eMSContext.SaveChangesAsync();

            var _Registration = new Models.Entity.Registration {
                StudentId        = _Student.Id,
                TestId           = request.TestID,
                Toaken           = request.Token,
                AccessLevelId    = request.AccessLevelID,
                RegistrationDate = DateTime.Now,
                TokenExpireTime  = DateTime.Now.AddDays(1)
            };
            await eMSContext.AddAsync(_Registration);

            await eMSContext.SaveChangesAsync();

            return(_Registration);
        }
示例#2
0
        public async Task <BaseResultModel <Models.Entity.Student> > GetPageStudentsAsync(int pageIndex, int pageSize, Dictionary <string, string> sortDic, StudentSearch search)
        {
            Expression <Func <Models.Entity.Student, bool> > expression = null;

            if (null != search)
            {
                Models.Entity.Student student = new Models.Entity.Student();
                where.Equal("FirstName", search.Name, "and");
                where.LessThanOrEqual(nameof(student.Birthday), search.Birthday, "and");
                expression = where.GetExpression();
            }
            return(await service.GetPageListAsync(pageIndex, pageSize, sortDic, expression));
        }
示例#3
0
        public async Task <IEnumerable <Models.Entity.Student> > GetStudentsAsync(StudentSearch search)
        {
            //Expression<Func<Models.Entity.Student, bool>> expression = c =>
            //     string.IsNullOrEmpty(search.Name)
            //     || c.FirstName == search.Name;
            Expression <Func <Models.Entity.Student, bool> > expression = null;

            if (null != search)
            {
                Models.Entity.Student student = new Models.Entity.Student();
                where.Equal("FirstName", search.Name, "and");
                where.LessThanOrEqual(nameof(student.Birthday), search.Birthday, "and");
                expression = where.GetExpression();
            }
            return(await service.GetListAsync(expression));
        }