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." }); }
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); }