public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var questionRepository = _unitOfWork.Repository <Question>(); var question = await questionRepository.GetByIdAsync(request.QuestionId); if (question == null) { throw new RestException(HttpStatusCode.NotFound, "Question not fount"); } var imageUploadResult = await _imageService.UploadImageAsync(request.File, "OnlineEducation/QuestionImage"); var questionImage = new QuestionImage { Url = imageUploadResult.Url, PublicId = imageUploadResult.PublicId, QuestionId = request.QuestionId }; var questionImageRepository = _unitOfWork.Repository <QuestionImage>(); questionImageRepository.Add(questionImage); var result = await _unitOfWork.CompleteAsync() > 0; if (result) { return(Unit.Value); } throw new Exception(ExceptionMessages.ProblemSavingChanges); }
private void PushData() { QuestionText.Text = Question.QuestionText; Answer1Text.Text = Question.Answer[0]; Answer2Text.Text = Question.Answer[1]; Answer3Text.Text = Question.Answer[2]; Answer4Text.Text = Question.Answer[3]; if (Question.HasOptionalQuestionImage) { try { var path = System.IO.Path.Combine(Environment.CurrentDirectory, "Images", Question.OptionalQuestionImageName); ImageSource imgSource = new BitmapImage(new Uri(path)); QuestionImage.BeginInit(); QuestionImage.Source = imgSource; QuestionImage.EndInit(); QuestionImage.Visibility = Visibility.Visible; } catch { Console.WriteLine("Image not found. Source: " + Question.OptionalQuestionImageName); } } }
public void init(QuestionImage pQi, Const.Position pPos, Const.Color pColor) { setQuestionImage(pQi); position = pPos; color = pColor; }
public QuestionImage Create(QuestionImage questionImage) { EQuestionImage eQuestionImage = EQuestion(questionImage); eQuestionImage = _iDQuestionImage.Create(eQuestionImage); return(Question(eQuestionImage)); }
void OnClick() { int lvl = int.Parse(GetComponentInChildren <Text>().text); QuestionImage.SetLvl(lvl); SceneManager.LoadScene(1); }
public void addQuestion(Subject s, List <Topic> diagnoses, List <string> images, string qText) { Question q = new Question { QuestionId = _questionID, SubjectId = s.SubjectId, text = qText, level = Levels.DEFAULT_LVL, points = Questions.QUESTION_INITAL_POINTS, timeAdded = DateTime.Now, isDeleted = false }; _db.addQuestion(q); foreach (Topic t in diagnoses) { Diagnosis d = new Diagnosis { QuestionId = _questionID, TopicId = t.TopicId, SubjectId = s.SubjectId }; _db.addDiagnosis(d); } foreach (string path in images) { QuestionImage i = new QuestionImage { ImageId = path, QuestionId = _questionID, }; _db.addImage(i); } _questionID++; }
public void addImage(QuestionImage i) { if (_questions.Where(q => q.QuestionId == i.QuestionId).Count() == 0 || _images.Where(image => image.ImageId.Equals(i.ImageId) && image.QuestionId == i.QuestionId).Count() != 0) { return; } _images.Add(i); }
public void addImage(QuestionImage i) { using (var db = new MedTrainDBContext()) { if (db.Questions.Find(i.QuestionId) == null || db.Images.Find(i.ImageId, i.QuestionId) != null) { return; } db.Images.Add(i); db.SaveChanges(); } }
private QuestionImage Question(EQuestionImage eQuestion) { QuestionImage returnQuestionImage = new QuestionImage { QuestionId = eQuestion.QuestionId, QuestionImageId = eQuestion.QuestionImageId, Url = eQuestion.Url }; return(returnQuestionImage); }
private EQuestionImage EQuestion(QuestionImage question) { EQuestionImage returnEQuestionImage = new EQuestionImage { QuestionId = question.QuestionId, QuestionImageId = question.QuestionImageId, Url = question.Url }; return(returnEQuestionImage); }
public ActionResult QuestionAddImage(QuestionImage questionImage, int questionId, HttpPostedFileBase file) { if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); fileName = fileName.Split('\\').Last(); //This will fix problems when uploading using IE var path = Path.Combine(Server.MapPath("~/Content/Images"), fileName); file.SaveAs(path); questionImage.Url = fileName; } _iFQuestionImage.Create(questionImage); return(Json(string.Empty)); }
Question createQuestion(int pId) { QuestionImage qi = new QuestionImage(); qi.id = pId; qi.animalType = getAnimalType(qi.id); // 01_frogs/f_[x] のxの部分を保存しておく qi.number = images_counter_array [(int)qi.animalType]; qi.imagePath = getImagePath(qi.animalType); Const.Position pos = getPosition(); Const.Color col = getColor(); Question q = new Question(); q.init(qi, pos, col); return(q); }
public JsonResult Delete(QuestionImage questionImage) { _iFQuestionImage.Delete(questionImage); return(Json(string.Empty)); }
void setQuestionImage(QuestionImage pQuestionImage) { questionImage = pQuestionImage; // sprite = Resources.Load<Sprite>(pQuestionImage.imagePath); }
public void Delete(QuestionImage QuestionImage) { _iDQuestionImage.Delete(EQuestion(QuestionImage)); }