Beispiel #1
0
        public HttpResponseMessage Delete(int answerId)
        {
            var answer = _repository.GetAnswer(answerId, ActiveModule.ModuleID);

            _repository.DeleteAnswer(answer);

            return(Request.CreateResponse(System.Net.HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public void DeleteAnswer(int id)
        {
            Answer Answer = _AnswerRepository.GetAnswer(id);

            if (Answer != null)
            {
                _AnswerRepository.DeleteAnswer(id);
                _logger.Log(LogLevel.Information, this, LogFunction.Delete, "Answer Deleted {AnswerId}", id);
            }
        }
Beispiel #3
0
        private void btnRemove_Tapped(object sender, TappedRoutedEventArgs e)
        {
            answerRepo.UpdateAnswers(answers);
            int    selected = Convert.ToInt32(((Button)sender).DataContext);
            Answer answer   = new Answer();

            answer = answerRepo.GetAnswer(selected);
            answerRepo.DeleteAnswer(answer);
            Frame.Navigate(typeof(QuestionDetail), (view), new SuppressNavigationTransitionInfo());
            Frame.BackStack.Remove(this.Frame.BackStack.Last());
        }
Beispiel #4
0
        public void DeleteQuestion(Question question)
        {
            List <Answer> answersForThisQuestion = _answerRepository.GetAllAnswersForGivenQuestion(question.Id);

            foreach (Answer ans in answersForThisQuestion)
            {
                _answerRepository.DeleteAnswer(ans);
            }

            _questionRepository.DeleteQuestion(question);
        }
Beispiel #5
0
 public async Task <IActionResult> Delete(int id)
 {
     try
     {
         if (await _repository.DeleteAnswer(id))
         {
             return(new NoContentResult());
         }
         return(NotFound(new
         {
             Error = $"Error during deletion answer with identifier {id}"
         }));
     }
     catch (Exception e)
     {
         return(new StatusCodeResult(500));
     }
 }
 public void DeleteAnswer(int answerId)
 {
     answerRepository.DeleteAnswer(answerId);
 }
Beispiel #7
0
        public ActionResult Edit(QuestionViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var Question = QuestionRepository.GetQuestionById(model.Id);
                    AutoMapper.Mapper.Map(model, Question);
                    Question.ModifiedUserId = WebSecurity.CurrentUserId;
                    Question.ModifiedDate   = DateTime.Now;
                    QuestionRepository.UpdateQuestion(Question);

                    if (model.DetailList != null && model.DetailList.Count > 0)
                    {
                        //Thêm/Hoặc cập nhật đáp án
                        var listAnswerOld = answerRepository.GetAllAnswer()
                                            .Where(item => item.QuestionId == Question.Id).ToList();

                        //Xóa những cái cũ
                        if (listAnswerOld != null && listAnswerOld.Count > 0)
                        {
                            foreach (var item in listAnswerOld)
                            {
                                var answer = model.DetailList.Where(i => i.Id == item.Id).FirstOrDefault();
                                if (answer == null)
                                {
                                    answerRepository.DeleteAnswer(item.Id);
                                }
                            }
                        }

                        //Thêm/cập nhật
                        foreach (var item in model.DetailList)
                        {
                            var answer = listAnswerOld.Where(i => i.Id == item.Id).FirstOrDefault();
                            if (answer == null)
                            {
                                answer = new Answer();
                                AutoMapper.Mapper.Map(item, answer);
                                answer.IsDeleted      = false;
                                answer.CreatedUserId  = WebSecurity.CurrentUserId;
                                answer.ModifiedUserId = WebSecurity.CurrentUserId;
                                answer.AssignedUserId = WebSecurity.CurrentUserId;
                                answer.CreatedDate    = DateTime.Now;
                                answer.ModifiedDate   = DateTime.Now;

                                answer.QuestionId = Question.Id;
                                answerRepository.InsertAnswer(answer);
                            }
                            else
                            {
                                answer.OrderNo     = item.OrderNo;
                                answer.Content     = item.Content;
                                answer.IsActivated = item.IsActivated;
                                answerRepository.UpdateAnswer(answer);
                            }
                        }
                    }

                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess;
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }

            return(View(model));

            //if (Request.UrlReferrer != null)
            //    return Redirect(Request.UrlReferrer.AbsoluteUri);
            //return RedirectToAction("Index");
        }
Beispiel #8
0
 public void DeleteAnswer(int AnswerID)
 {
     ar.DeleteAnswer(AnswerID);
 }
 public void DeleteAnswer(Answer answer)
 {
     _repository.DeleteAnswer(answer);
 }
Beispiel #10
0
 public void DeleteAnswer(Guid AnswerId)
 {
     _answerRepository.DeleteAnswer(AnswerId);
 }
Beispiel #11
0
 public int DeleteAnswer(int id)
 {
     return(answerRepository.DeleteAnswer(id));
 }