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);
        }
        public async Task <object> Handle(CreateQuestion request, CancellationToken cancellationToken)
        {
            var Question = new Models.Entity.Question
            {
                CategoryId     = request.CategoryID,
                QuestionTypeId = request.QuestionTypeID,
                Lebel          = request.Lebel,
                Point          = request.Point,
                IsActive       = request.isActive
            };
            await EMSContext.AddAsync(Question);

            await EMSContext.SaveChangesAsync(cancellationToken);

            var img = new Models.Entity.Photo
            {
                FileName = request.FileName,
                RecordId = Question.Id,
                Base64   = request.Base64
            };
            await EMSContext.AddAsync(img);

            await EMSContext.SaveChangesAsync(cancellationToken);

            IList <Choice> Choices = new List <Choice> {
                new Choice {
                    QuestionId = Question.Id, Label = request.Choice1, Points = request.Choice1Score
                },
                new Choice {
                    QuestionId = Question.Id, Label = request.Choice2, Points = request.Choice2Score
                },
                new Choice {
                    QuestionId = Question.Id, Label = request.Choice3, Points = request.Choice3Score
                },
                new Choice {
                    QuestionId = Question.Id, Label = request.Choice4, Points = request.Choice4Score
                }
            };
            await EMSContext.AddRangeAsync(Choices);

            await EMSContext.SaveChangesAsync();



            //EMSContext.Model.en

            //await EMSContext.AddAsync(Choices);
            //await EMSContext.SaveChangesAsync(cancellationToken);
            return(new
            {
                Message = "New Question Type added."
            });
        }
Beispiel #3
0
        public async Task <object> Handle(CreateTest request, CancellationToken cancellationToken)
        {
            var Test = new Models.Entity.Test {
                Name              = request.Name,
                Description       = request.Description,
                IsActive          = request.IsActive,
                DurationInMinutes = request.DurationInMinutes
            };
            await EMSContext.AddAsync(Test);

            await EMSContext.SaveChangesAsync(cancellationToken);

            return(Test);
        }
        public async Task <object> Handle(CreateQuestionTypeCommand request, CancellationToken cancellationToken)
        {
            var questionType = new Models.Entity.QuestionType
            {
                Name = request.Name
            };

            await eMSContext.AddAsync(questionType);

            await eMSContext.SaveChangesAsync(cancellationToken);

            return(new
            {
                Message = "New Question Type added."
            });
        }
Beispiel #5
0
        public async Task <object> Handle(SavePhotoCommand request, CancellationToken cancellationToken)
        {
            var _photo = new Models.Entity.Photo
            {
                RecordId = request.RecordId,
                FileName = request.FileName,
                Path     = request.Path,
                Base64   = request.Base64 //,
                                          //File = request.File
            };
            await eMSContext.AddAsync(_photo);

            await eMSContext.SaveChangesAsync();

            return(_photo);
        }