Beispiel #1
0
        public void Update(TestEditDTO dto)
        {
            var TestUpdate = this.tests.All.Where(t => t.Name == dto.Name)
                             .First();


            //var id = TestUpdate.Id;
            //dto.Id = id.ToString();
            //var catId = TestUpdate.CategoryId;
            //dto.CategoryId = catId.ToString();

            //this.mapper.MapTo(dto, TestUpdate);

            //TestUpdate.Id = id;
            //TestUpdate.CategoryId = catId;
            TestUpdate.TimeInMinutes = dto.TimeInMinutes;
            TestUpdate.Name          = dto.Name;
            TestUpdate.Status        = dto.Status;



            this.tests.Update(TestUpdate);

            foreach (var item in dto.Questions)
            {
                if (item.IsDeleted == true)
                {
                    var x = this.mapper.MapTo <Question>(item);
                    this.questions.RealDelete(x);
                }
                else if (item.Id != null)
                {
                    var x = this.mapper.MapTo <Question>(item);
                    this.UpdateQuestions(x);
                }
                else
                {
                    var x = this.mapper.MapTo <Question>(item);
                    x.TestId = TestUpdate.Id;
                    this.questions.Add(x);
                }
            }
            this.saver.SaveChanges();
        }
Beispiel #2
0
        //private void UpdateAnswers(Answer item)
        //{
        //    this.answers.Update(item);

        //}

        public void PublishedUpdate(TestEditDTO dto)
        {
            var listOfAnswers = new List <AnswerEditDTO>();

            foreach (var item in dto.Questions)
            {
                foreach (var A in item.Answers)
                {
                    var x = this.mapper.MapTo <Answer>(A);
                    this.answers.Update(x);
                    //listOfAnswers.Add(A);
                }
            }

            // var Answers = this.mapper.EnumProjectTo<Answer>(listOfAnswers);



            this.saver.SaveChanges();
        }
Beispiel #3
0
 public IActionResult EditPublishedTest(TestEditDTO test)
 {
     this.createTestService.PublishedUpdate(test);
     this.utaService.RecalculateAllTakenTestsWithName(test.Name);
     return(this.RedirectToAction("ShowResults", "Results"));
 }
Beispiel #4
0
        public IActionResult EditTest(TestEditDTO test)
        {
            this.createTestService.Update(test);

            return(this.RedirectToAction("ShowResults", "Results"));
        }