Ejemplo n.º 1
0
 public CometClientProcessor()
 {
     // Dependency Injection (design pattern ) implementation/realization other class in Constructor
     this._questionService = new QuestionService();
     this._answerService = new AnswerService();
     this._gameService = new GameService();
 }
Ejemplo n.º 2
0
 public QuestionController(QuestionService questionService, QuizService quizService, UserService userService)
 {
     _questionService = questionService;
     _quizService     = quizService;
     _userService     = userService;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Конструирует объект контроллера вопросов
 /// </summary>
 public QuestionsController()
 {
     Context = new UniversalTestingContext();
     Service = new QuestionService(Context);
 }
        public async Task <IActionResult> AllAsync(int quizId)
        {
            var questions = await QuestionService.All(quizId);

            return(new JsonResult(questions.Select(q => Mapper.Map <QuestionDetailsServiceModel, QuestionViewModel>(q)), JsonSettings));
        }
Ejemplo n.º 5
0
        public List <Question> BuildQuizQuestions()
        {
            IQuestionService questionService = new QuestionService();

            return(questionService.BuildQuestions().OrderBy(x => x.QuestionNumber).ToList());
        }
Ejemplo n.º 6
0
        public ActionResult Edit(string id, GameEditModel model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                ViewBag.VersionName = new SelectList(ctx.Versions.ToList(), "Name", "Name");
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                if (model.GameBaseId != id)
                {
                    ModelState.AddModelError("", "Id Mismatch");
                    return(View(model));
                }

                //successful here
                var qsvc     = new QuestionService();
                var csvc     = new CategoryService();
                var playerId = User.Identity.GetUserId();
                var player   = ctx.Users.Single(e => e.Id == playerId);
                var game     = ctx.GameBases.Single(e => e.PlayerId == playerId);
                var gsvc     = new GameService();

                if (model.Answer != null)
                {
                    var    boolean       = true;
                    var    question      = qsvc.GetQuestionByIdForGame(model.QuestionId);
                    string correctAnswer = question.Answers.Single(e => e.IsCorrectSpelling == boolean).Text;
                    model.Question = new Question();
                    model.Question.IsUserGenerated = question.IsUserGenerated;
                    bool isCorrect = gsvc.CheckIfCorrect(model.Answer, question.Answers.ToList());
                    if (model.PlayerTurn == 1 && !model.Question.IsUserGenerated)
                    {
                        gsvc.IncrementAnswered(player, model, ctx);
                    }
                    if (isCorrect)
                    {
                        if (model.PlayerTurn == 1 && !model.Question.IsUserGenerated)
                        {
                            gsvc.IncrementCorrect(player, model, ctx);
                        }
                        gsvc.UpdateAPie(game, model, ctx);
                        TempData["Correct"] = "Correct.";
                        if (gsvc.UpdateGame(model))
                        {
                            if (gsvc.CheckWinCondition(game))
                            {
                                return(RedirectToAction("Win"));
                            }

                            return(RedirectToAction("Edit"));
                        }
                    }
                    if (!isCorrect)
                    {
                        model.PlayerTurn = gsvc.UpdatePlayerTurn(model);
                        if (model.PlayerTurn == 1)
                        {
                            TempData["Incorrect"] = $"Incorrect. The correct answer was {correctAnswer}. Turn goes to player {model.PlayerTurn}";
                        }
                        else
                        {
                            TempData["Incorrect"] = $"Incorrect. The correct answer was {correctAnswer}. Turn goes to {model.DisplayName}";
                        }
                    }
                }
                if (gsvc.UpdateGame(model))
                {
                    return(RedirectToAction("Edit"));
                }

                ModelState.AddModelError("", "Something went wrong");
                model.GameVersion = null;
                return(View(model));
            }
        }
Ejemplo n.º 7
0
 public QuestionsController(QuestionService svc, ResponseService ressvc)
 {
     _svc    = svc;
     _ressvc = ressvc;
 }
 public QuestionsController(QuestionService qs)
 {
     _qs = qs;
 }
Ejemplo n.º 9
0
 public QuestionsController(IDbContext dbContext)
 {
     _questionService = new QuestionService(dbContext);
 }
Ejemplo n.º 10
0
 public QuestionsController(dbcontext context)
 {
     qS = new QuestionService(context);
     uS = new UserService(context);
 }
Ejemplo n.º 11
0
        public void NonExistingQuiz()
        {
            QuestionService questionService = new QuestionService();

            Assert.Throws(typeof(System.IO.FileNotFoundException), () => questionService.GetData(@"../../../../nullQuestions.txt"));
        }
 public TestController()
 {
     testservice = new TestService();
     qsservice   = new QuestionService();
 }
Ejemplo n.º 13
0
 public QuestionController()
 {
     this.service = new QuestionService();
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Save job into database
        /// </summary>
        /// <returns></returns>
        public int SaveJob()
        {
            var book = _bookStateHolder.Load();
            //if(book.AppointmentDate!="")

            var cust       = new CustomerService(_dataContext);
            var prod       = new ProductService(_dataContext);
            var user       = new UserService(_dataContext);
            var store      = new StoreService(_dataContext);
            var job        = new BookRepair_JobModel();
            var quest      = new QuestionService(_dataContext);
            var jobService = new JobService(_dataContext);

            var prodInfo    = prod.GetGeneralInfoFromSession();
            var repairAgent = GetAgentRepairInfo();

            job.DateOfPurchase  = book.DateOfPurchase;
            job.SerialNumber    = prodInfo.SerialNumber;
            job.ItemCondition   = prodInfo.OriginalCondition;
            job.DateOfPurchase  = prodInfo.DateOfPurchase;
            job.StoreNumber     = book.StoreNumber;
            job.TillNumber      = book.TillNumber;
            job.TransNumber     = prodInfo.TransactionInfo;
            job.SelectedType    = book.Type;
            job.FaultDescr      = book.FaultDescr + " \n" + quest.GetAnswersFromSession();
            job.UserID          = user.GetUserId();
            job.EngineerId      = book.EngineerId;
            job.AppointmentDate = book.AppointmentDate;
            job.StoreCollection = book.StoreCollection;
            SetAcceptJobFlag(false);
            int custId   = cust.GetCustomerIdFromSession();
            var customer = cust.GetCustomerInfo();
            int Jobid    = _reporsitory.UpdateJob(job, custId, prod.GetModelId(), (DateTime)prod.GetTimeBookRepairClick(), book.ServiceId, store.GetStoreId());

            if (!string.IsNullOrEmpty(repairAgent.BookingUrl))
            {
                OnlineBookingService     onlineBookingService = new OnlineBookingService();
                OnlineBookRequestDetails model = new OnlineBookRequestDetails();
                // model.InjectFrom(ProductService.SessionInfo);
                model.ServiceID            = Jobid;
                model.CustomerTitle        = customer.TitleName;
                model.CustomerForename     = customer.Forename;
                model.CustomerSurname      = customer.Surname;
                model.CustomerStreet       = customer.Addr1;
                model.CustomerPostcode     = customer.Postcode;
                model.CustomerAddressTown  = customer.Town;
                model.CustomerWorkTelNo    = customer.LandlineTel;
                model.CustomerMobileNo     = customer.MobileTel;
                model.CustomerEmailAddress = customer.Email;
                model.SupplyDat            = prodInfo.DateOfPurchase.ToString("yyyy-MM-dd");
                //model.CustAplID = prodInfo.CustaplId;
                model.ApplianceCD = "";
                //model.Model = prodInfo.ItemNumber;
                //model.AltCode = prodInfo.ItemCode;
                // cast online booking - skyline  Argos Cat No (MODEL) should go into Skyline ProductCode field
//Argos Brand Model (ALTCODE)  should go into Skyline ModelNo field

                model.Model   = prodInfo.ItemCode;
                model.AltCode = prodInfo.ItemNumber;
                model.SNO     = job.SerialNumber;
                model.MFR     = prodInfo.ModelBrand;

                //model.PolicyNumber =prodInfo.p
                model.ReportFault = job.FaultDescr;
                model.ClientID    = store.GetStoreId();
                model.StatusID    = 4;

                //  model.VisitDate = DateTime.Parse(job.AppointmentDate);
                //  model.EngineerID = job.EngineerId.Value;
                model.SlotID = book.Slotid;
                //   model.CallType = job.StoreCollection ? "1 Store Collection" : "2 In Home Repair";//repairAgent.InHomeAvailable?"1 Store Collection":( job.StoreCollection ? "1 Store Collection" : "2 In Home Repair");
                model.CallType = !repairAgent.InHomeAvailable ? "1 Store Collection":(job.StoreCollection ? "1 Store Collection" : "2 In Home Repair");
                var response = onlineBookingService.BookJob(model);
                Log.File.ErrorFormat("Error {0}: {1}. ", response.ErrorMsg, response.BookSuccessfully);



                if (response.BookSuccessfully)
                {
                    _reporsitory.UpdateJobClientRef(Jobid, response.ServiceID);

                    HttpContext.Current.Session["ClientRef"] = response.ServiceID;
                }
                else
                {
                    book.OnlineBookingFailed = true;
                }
            }
            if (book.FieldsForInspection != null && book.FieldsForInspection.Count > 0)
            {
                InspectionRepository ins = new InspectionRepository(_dataContext);
                book.FieldsForInspection.ForEach(s => s.ServiceId = Jobid);
                ins.SaveSpecificInspection(book.FieldsForInspection);
            }
            return(Jobid);
        }
Ejemplo n.º 15
0
        private void PlayAsDasher()
        {
            QuestionService.SetDasher(PlayerService.Player);

            NavigationService.BecameDasher();
        }
Ejemplo n.º 16
0
        public App()
        {
            var medicationRepository           = new MedicationRepository(new Stream <Medication>(MEDICATION_FILE));
            var diagnosisRepository            = new DiagnosisRepository(new Stream <Diagnosis>(DIAGNOSIS_FILE));
            var allergenRepository             = new AllergensRepository(new Stream <Allergens>(ALLERGEN_FILE));
            var categoryRepository             = new MedicationCategoryRepository(new Stream <MedicationCategory>(CATEGORY_FILE));
            var symptomsRepository             = new SymptomsRepository(new Stream <Symptoms>(SYMPTOMS_FILE));
            var ingredientsRepository          = new MedicationIngredientRepository(new Stream <MedicationIngredient>(INGREDIENTS_FILE));
            var specializationRepository       = new SpecializationRepository(new Stream <Specialization>(SPECIALIZATION_FILE));
            var cityRepository                 = new CityRepository(new Stream <City>(CITY_FILE));
            var addressRepository              = new AddressRepository(new Stream <Address>(ADDRESS_FILE), cityRepository);
            var stateRepository                = new StateRepository(new Stream <State>(STATE_FILE));
            var hospitalRepository             = new HospitalRepository(new Stream <Hospital>(HOSPITAL_FILE));
            var departmentRepository           = new DepartmentRepository(hospitalRepository, new Stream <Department>(DEPARTMENT_FILE));
            var roomRepository                 = new RoomRepository(departmentRepository, new Stream <Room>(ROOM_FILE));
            var userRepository                 = new UserRepository(new Stream <RegisteredUser>(USER_FILE), cityRepository, addressRepository, departmentRepository, roomRepository);
            var renovationRepository           = new RenovationRepository(roomRepository, new Stream <Renovation>(RENOVATION_FILE));
            var medicalRecordRepository        = new MedicalRecordRepository(new Stream <MedicalRecord>(RECORD_FILE), diagnosisRepository, medicationRepository, userRepository);
            var bedRepository                  = new BedRepository(roomRepository, medicalRecordRepository, new Stream <Bed>(BED_FILE));
            var equipmentTypeRepository        = new EquipmentTypeRepository(new Stream <EquipmentType>(EQUIPMENT_TYPE_FILE));
            var equipmentRepository            = new HospitalEquipmentRepository(new Stream <HospitalEquipment>(EQUIPMENT_FILE));
            var treatmentsRepository           = new TreatmentRepository(medicationRepository, departmentRepository, new Stream <Treatment>(TREATMENTS_FILE));
            var examinationSurgeryRepository   = new ExaminationSurgeryRepository(treatmentsRepository, medicalRecordRepository, userRepository, new Stream <ExaminationSurgery>(EXAMINATION_SURGERY_FILE));
            var emergencyRequestRepository     = new EmergencyRequestRepository(medicalRecordRepository, new Stream <EmergencyRequest>(EMERGENCY_REQUEST_FILE));
            var vaccinesRepository             = new VaccinesRepository(new Stream <Vaccines>(VACCINES_FILE));
            var notificationRepository         = new NotificationRepository(userRepository, new Stream <Notification>(NOTIFICATION_FILE));
            var articleRepository              = new ArticleRepository(userRepository, new Stream <Article>(ARTICLE_FILE));
            var questionRepository             = new QuestionRepository(userRepository, new Stream <Question>(QUESTIONS_FILE));
            var doctorReviewsRepository        = new DoctorReviewRepository(userRepository, new Stream <DoctorReview>(DOCTOR_REVIEWS_FILE));
            var feedbackRepository             = new FeedbackRepository(userRepository, new Stream <Feedback>(FEEDBACK_FILE));
            var surveyRepository               = new SurveyRepository(userRepository, new Stream <Survey>(SURVEY_FILE));
            var appointmentsRepository         = new AppointmentRepository(userRepository, medicalRecordRepository, roomRepository, new Stream <Appointment>(APPOINTMENTS_FILE));
            var workDayRepository              = new WorkDayRepository(userRepository, new Stream <WorkDay>(WORK_DAY_FILE));
            var vacationRequestRepository      = new VacationRequestRepository(userRepository, new Stream <VacationRequest>(VACATION_REQUEST_FILE));
            var reportsRepository              = new ReportRepository(new Stream <Report>(REPORTS_FILE));
            var labTestTypeRepository          = new LabTestTypeRepository(new Stream <LabTestType>(LAB_TEST_TYPE_FILE));
            var validationMedicationRepository = new ValidationMedicationRepository(new Stream <ValidationMed>(VALIDATION_FILE), userRepository, medicationRepository);

            var equipmentTypeService        = new EquipmentTypeService(equipmentTypeRepository);
            var medicationService           = new MedicationService(medicationRepository, validationMedicationRepository);
            var diagnosisService            = new DiagnosisService(diagnosisRepository);
            var allergenService             = new AllergensService(allergenRepository);
            var categoryService             = new MedicationCategoryService(categoryRepository);
            var symptomsService             = new SymptomsService(symptomsRepository);
            var ingredientsService          = new MedicationIngredientService(ingredientsRepository);
            var specializationService       = new SpecializationService(specializationRepository);
            var cityService                 = new CityService(cityRepository);
            var stateService                = new StateService(stateRepository);
            var addressService              = new AddressService(addressRepository);
            var notificationService         = new NotificationService(notificationRepository, userRepository, medicalRecordRepository);
            var validationMedicationService = new ValidationMedicationService(validationMedicationRepository, notificationService);
            var hospitalService             = new HospitalService(hospitalRepository);
            var departmentService           = new DepartmentService(departmentRepository);
            var bedService                = new BedService(bedRepository);
            var medicalRecordService      = new MedicalRecordService(medicalRecordRepository);
            var treatmentService          = new TreatmentService(treatmentsRepository, notificationService);
            var examiantionSurgeryService = new ExaminationSurgeryService(examinationSurgeryRepository);
            var emergencyRequestService   = new EmergencyRequestService(emergencyRequestRepository, notificationService);
            var vaccinesService           = new VaccinesService(vaccinesRepository);
            var articleService            = new ArticleService(articleRepository);
            var questionService           = new QuestionService(questionRepository, notificationService);
            var doctorsReviewService      = new DoctorReviewService(doctorReviewsRepository);
            var feedbackService           = new FeedbackService(feedbackRepository);
            var surveyService             = new SurveyService(surveyRepository);
            var userService               = new UserService(userRepository, medicalRecordService);
            var workDayService            = new WorkDayService(workDayRepository, MAX_HOURS_PER_WEEK);
            var appointmentService        = new AppointmentService(appointmentsRepository, workDayService, notificationService, VALID_HOURS_FOR_SCHEDULING, APPOINTMENT_LENGTH_IN_MINUTES,
                                                                   SURGERY_LENGTH_IN_MINUTES, START_WORKING_HOURS, END_WORKING_HOURS);
            var vacationRequestService      = new VacationRequestService(vacationRequestRepository, notificationService, NUMBER_OF_ALLOWED_VACAY_REQUESTS);
            var reportsService              = new ReportService(reportsRepository, treatmentsRepository, medicationRepository, examinationSurgeryRepository, roomRepository);
            var labTestTypeService          = new LabTestTypeService(labTestTypeRepository);
            var roomService                 = new RoomService(roomRepository, appointmentsRepository);
            var hospitalEquipmentService    = new HospitalEquipmentService(equipmentRepository);
            var renovationService           = new RenovationService(renovationRepository, roomService, appointmentsRepository, hospitalEquipmentService, notificationService, RENOVATION_DAYS_RESTRICTION, RENOVATION_DAYS_RESTRICTION);
            var availableAppointmentService = new AvailableAppointmentService(appointmentsRepository, workDayService, VALID_HOURS_FOR_SCHEDULING,
                                                                              APPOINTMENT_LENGTH_IN_MINUTES, SURGERY_LENGTH_IN_MINUTES, START_WORKING_HOURS, END_WORKING_HOURS);

            equipmentTypeController        = new EquipmentTypeController(equipmentTypeService);
            medicationController           = new MedicationController(medicationService);
            userController                 = new UserController(userService);
            diagnosisController            = new DiagnosisController(diagnosisService);
            symptomsController             = new SymptomsController(symptomsService);
            categoryController             = new MedicationCategoryController(categoryService);
            allergensController            = new AllergensController(allergenService);
            vaccinesController             = new VaccinesController(vaccinesService);
            labTestTypeController          = new LabTestTypeController(labTestTypeService);
            medicationIngredientController = new MedicationIngredientController(ingredientsService);
            cityController                 = new CityController(cityService);
            specializationController       = new SpecializationController(specializationService);
            addressController              = new AddressController(addressService);
            stateController                = new StateController(stateService);
            departmentController           = new DepartmentController(departmentService);
            hospitalController             = new HospitalController(hospitalService);
            roomController                 = new RoomController(roomService);
            renovationController           = new RenovationController(renovationService);
            hospitalEquipmentController    = new HospitalEquipmentController(hospitalEquipmentService);
            medicalRecordController        = new MedicalRecordController(medicalRecordService);
            treatmentController            = new TreatmentController(treatmentService);
            examinationSurgeryController   = new ExaminationSurgeryController(examiantionSurgeryService);
            articleController              = new ArticleController(articleService);
            questionController             = new QuestionController(questionService);
            doctorReviewController         = new DoctorReviewController(doctorsReviewService);
            surveyController               = new SurveyController(surveyService);
            feedbackController             = new FeedbackController(feedbackService);
            workDayController              = new WorkDayController(workDayService);
            reportController               = new ReportController(reportsService);
            validationMedicationController = new ValidationMedicationController(validationMedicationService);
            vacationRequestController      = new VacationRequestController(vacationRequestService);
            bedController = new BedController(bedService);
            emergencyRequestController     = new EmergencyRequestController(emergencyRequestService);
            appointmentController          = new AppointmentController(appointmentService);
            notificationController         = new NotificationController(notificationService);
            availableAppointmentController = new AvailableAppointmentController(availableAppointmentService);

            validations = new Validations(UNDERAGE_RESTRICTION);
        }
Ejemplo n.º 17
0
 public ServiceTests()
 {
     _questionRepository = A.Fake <IQuestionRepository>();
     _fixture            = new Fixture();
     _questionService    = new QuestionService(_questionRepository);
 }
Ejemplo n.º 18
0
        public async Task <Search> RunAsync(QuestionService service)
        {
            var result = await service.GetQuestionsAsync("java");

            return(result);
        }
Ejemplo n.º 19
0
        public QuestionProvider(ICategoryProvider categoryProvider)
        {
            var generator = new QuestionService(categoryProvider, 50);

            _questions = generator.Get();
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QuestionController" /> class.
 /// </summary>
 /// <param name="questionService">The question service.</param>
 /// <param name="personQualityService">The person quality service.</param>
 public QuestionController(QuestionService questionService, PersonQualityService personQualityService)
 {
     _questionService      = questionService;
     _personQualityService = personQualityService;
 }
Ejemplo n.º 21
0
 public QuestionsController(MySqlConnection conn)
 {
     _questionService = new QuestionService(conn);
 }
 public TestController(ITestService testService, QuestionService questionService, AnswerService answerService)
 {
     this.testService     = testService;
     this.questionService = questionService;
     this.answerService   = answerService;
 }
Ejemplo n.º 23
0
 public IActionResult Submit(string userId, string response)
 {
     QuestionService.AddAnswer(userId, response);
     return(RedirectToAction("Question", new { userId }));
 }
Ejemplo n.º 24
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            logService = new LogService();
            bool         isChange = false;
            LogViewModel logModel = new LogViewModel();


            var user   = (UserViewModel)HttpContext.Current.Session["user"];
            int?userId = null;

            if (user != null)
            {
                userId = user.Id;
            }

            ILogService            logger                 = new LogService();
            CourseService          courseService          = new CourseService();
            CategoryService        categoryService        = new CategoryService();
            LearningOutcomeService learningOutcomeService = new LearningOutcomeService();
            LevelService           levelService           = new LevelService();
            int?targetId = null;
            int?importId = null;
            QuestionViewModel oldQuestionModel = new QuestionViewModel();
            QuestionViewModel newQuestionModel = new QuestionViewModel();
            IQuestionService  questionService  = new QuestionService();

            int[] ids;

            if (IdParamName != null && filterContext.ActionParameters.ContainsKey(IdParamName))
            {
                targetId = filterContext.ActionParameters[IdParamName] as Int32?;
            }
            else if (ObjectParamName != null && filterContext.ActionParameters.ContainsKey(ObjectParamName))
            {
                newQuestionModel = filterContext.ActionParameters[ObjectParamName] as QuestionViewModel;
                targetId         = newQuestionModel.GetType().GetProperty(IdParamName).GetValue(newQuestionModel, null) as Int32?;
                if (Action.Equals(Enum.GetName(typeof(LogEnum), LogEnum.Update)) && TargetName.ToLower().Equals("question"))
                {
                    oldQuestionModel = questionService.GetQuestionById(newQuestionModel.Id);
                }
            }
            #region update Log
            if (Action.Equals(Enum.GetName(typeof(LogEnum), LogEnum.Update)) && TargetName.ToLower().Equals("question"))
            {
                QuestionViewModel questionViewModel = new QuestionViewModel();
                oldQuestionModel.QuestionContent = WebUtility.HtmlDecode(oldQuestionModel.QuestionContent);
                if (oldQuestionModel.CategoryId != 0)
                {
                    oldQuestionModel.Category = categoryService.GetCategoryById(oldQuestionModel.CategoryId).Name;
                }

                oldQuestionModel.Category            = oldQuestionModel.CategoryId != 0 ? oldQuestionModel.Category : "[None of Category]";
                oldQuestionModel.LevelName           = oldQuestionModel.LevelId != 0 ? oldQuestionModel.LevelName : "[None of Level]";
                oldQuestionModel.LearningOutcomeName = oldQuestionModel.LearningOutcomeId != 0 ? oldQuestionModel.LearningOutcomeName : "[None of LOC]";
                for (int i = 0; i < oldQuestionModel.Options.Count; i++)
                {
                    oldQuestionModel.Options[i].OptionContent = WebUtility.HtmlDecode(oldQuestionModel.Options[i].OptionContent);
                }
                logModel.OldValue = JsonConvert.SerializeObject(oldQuestionModel);

                if (newQuestionModel.QuestionContent != "")
                {
                    newQuestionModel.QuestionCode = oldQuestionModel.QuestionCode != null?oldQuestionModel.QuestionCode.ToString() : "";

                    newQuestionModel.CourseId = oldQuestionModel.CourseId;
                    //newQuestionModel.CategoryId = oldQuestionModel.CategoryId;
                    if (newQuestionModel.CategoryId != 0)
                    {
                        newQuestionModel.Category = categoryService.GetCategoryById(newQuestionModel.CategoryId).Name;
                    }
                    newQuestionModel.Category = newQuestionModel.CategoryId != 0 ? newQuestionModel.Category : "[None of Category]";
                    if (newQuestionModel.LevelId != 0)
                    {
                        newQuestionModel.LevelName = levelService.GetLevelById(newQuestionModel.LevelId).Name;
                    }
                    newQuestionModel.LevelName = newQuestionModel.LevelId != 0 ? newQuestionModel.LevelName : "[None of Level]";
                    if (newQuestionModel.LearningOutcomeId != 0)
                    {
                        newQuestionModel.LearningOutcomeName = learningOutcomeService.GetLearingOutcomeById(newQuestionModel.LearningOutcomeId).Name;
                    }
                    newQuestionModel.LearningOutcomeName = newQuestionModel.LearningOutcomeId != 0 ? newQuestionModel.LearningOutcomeName : "[None of LOC]";
                    //newQuestionModel.Image = oldQuestionModel.Image;
                    newQuestionModel.CourseName = oldQuestionModel.CourseName;
                    //newQuestionModel.LearningOutcomeName = oldQuestionModel.LearningOutcomeName;
                    //newQuestionModel.LevelName = oldQuestionModel.LevelName;
                    newQuestionModel.QuestionContent = WebUtility.HtmlDecode(newQuestionModel.QuestionContent);
                    for (int i = 0; i < newQuestionModel.Options.Count; i++)
                    {
                        newQuestionModel.Options[i].OptionContent = WebUtility.HtmlDecode(newQuestionModel.Options[i].OptionContent);
                    }
                    logModel.NewValue = JsonConvert.SerializeObject(newQuestionModel);
                }
                logModel.OldValue   = JsonConvert.SerializeObject(oldQuestionModel);
                logModel.NewValue   = JsonConvert.SerializeObject(newQuestionModel);
                logModel.UserId     = userId;
                logModel.TargetId   = targetId;
                logModel.Action     = Action;
                logModel.TargetName = TargetName;
                logModel.LogDate    = DateTime.Now;
                logModel.Message    = Message;
                logModel.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
                logModel.Method     = filterContext.ActionDescriptor.ActionName;
                logModel.Fullname   = Fullname;
                logModel.UserCode   = UserCode;
                logger.Log(logModel);
                isChange = true;
            }

            if (Action.Equals(Enum.GetName(typeof(LogEnum), LogEnum.Update)) && TargetName.ToLower().Equals("rule"))
            {
            }
            #endregion

            #region move Question Log
            else if (Action.Equals(Enum.GetName(typeof(LogEnum), LogEnum.Move)) && TargetName.ToLower().Equals("question"))
            {
                int                      categoryId               = 0;
                int                      learningOutComeId        = 0;
                int                      levelId                  = 0;
                CourseViewModel          courseView               = new CourseViewModel();
                LearningOutcomeViewModel learningOutcomeViewModel = new LearningOutcomeViewModel();
                LevelViewModel           levelViewModel           = new LevelViewModel();
                CategoryViewModel        categoryView             = new CategoryViewModel();

                if (filterContext.ActionParameters.ContainsKey(IdParamName))
                {
                    ids               = filterContext.ActionParameters[IdParamName] as int[];
                    categoryId        = filterContext.ActionParameters[CateParamName] != null ? (int)filterContext.ActionParameters[CateParamName] : 0;
                    learningOutComeId = filterContext.ActionParameters[LocParamName] != null ? (int)filterContext.ActionParameters[LocParamName] : 0;
                    levelId           = (int)filterContext.ActionParameters[LevelParamName];
                    if (ids != null)
                    {
                        foreach (var item in ids)
                        {
                            if (item != 0)
                            {
                                targetId         = item;
                                oldQuestionModel = questionService.GetQuestionById((int)targetId);
                                if (oldQuestionModel.CategoryId != 0)
                                {
                                    oldQuestionModel.Category = categoryService.GetCategoryById(oldQuestionModel.CategoryId).Name;
                                }
                                oldQuestionModel.Category = oldQuestionModel.CategoryId != 0 ? oldQuestionModel.Category : "[None of Category]";

                                oldQuestionModel.LevelName           = oldQuestionModel.LevelId != 0 ? oldQuestionModel.LevelName : "[None of Level]";
                                oldQuestionModel.LearningOutcomeName = oldQuestionModel.LearningOutcomeId != 0 ? oldQuestionModel.LearningOutcomeName : "[None of LOC]";
                                newQuestionModel.LearningOutcomeId   = learningOutComeId;
                                newQuestionModel.LevelId             = levelId;
                                if (categoryId != 0)
                                {
                                    newQuestionModel.Category = categoryService.GetCategoryById(categoryId).Name;
                                }
                                newQuestionModel.Category = categoryId != 0 ? newQuestionModel.Category : "[None of Category]";
                                //newQuestionModel.CourseId = oldQuestionModel.CourseId;

                                courseView = courseService.GetCourseById(oldQuestionModel.CourseId);
                                newQuestionModel.CourseName = courseView.Name;
                                if (learningOutComeId != 0)
                                {
                                    learningOutcomeViewModel = learningOutcomeService.GetLearingOutcomeById(learningOutComeId);
                                }
                                newQuestionModel.LearningOutcomeName = learningOutComeId != 0 ? learningOutcomeViewModel.Name : "[None of LOC]";
                                if (levelId != 0)
                                {
                                    levelViewModel = levelService.GetLevelById(levelId);
                                }
                                newQuestionModel.LevelName = levelId != 0 ? levelViewModel.Name : "[None of level]";
                                //newQues.CourseName = oldValue.CourseName;
                                //newQues.LearningOutcomeName = oldValue.LearningOutcomeName;
                                //newQues.LevelName = oldValue.LevelName;
                                newQuestionModel.QuestionContent = oldQuestionModel.QuestionContent;
                                newQuestionModel.Id           = oldQuestionModel.Id;
                                newQuestionModel.QuestionCode = oldQuestionModel.QuestionCode;
                                newQuestionModel.Options      = oldQuestionModel.Options;

                                #region log to db
                                logModel.OldValue   = JsonConvert.SerializeObject(oldQuestionModel);
                                logModel.NewValue   = JsonConvert.SerializeObject(newQuestionModel);
                                logModel.UserId     = userId;
                                logModel.TargetId   = targetId;
                                logModel.Action     = Action;
                                logModel.TargetName = TargetName;
                                logModel.LogDate    = DateTime.Now;
                                logModel.Message    = Message;
                                logModel.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
                                logModel.Method     = filterContext.ActionDescriptor.ActionName;
                                logger.Log(logModel);

                                logModel = new LogViewModel();
                                isChange = true;
                                #endregion
                            }
                        }
                    }
                }
            }

            #endregion

            else if (isChange == false)
            {
                logModel.OldValue = OldValue;
                logModel.NewValue = NewValue;
                if (newQuestionModel != null && !String.IsNullOrWhiteSpace(NewValue))
                {
                    for (int i = 0; i < newQuestionModel.Options.Count; i++)
                    {
                        newQuestionModel.Options[i].OptionContent = WebUtility.HtmlDecode(newQuestionModel.Options[i].OptionContent);
                    }
                    logModel.NewValue = JsonConvert.SerializeObject(newQuestionModel);
                }
                if (Action.Equals(Enum.GetName(typeof(LogEnum), LogEnum.Cancel)))
                {
                    logModel.Status = (int)StatusEnum.Canceled;
                }
                if (Action.Equals(Enum.GetName(typeof(LogEnum), LogEnum.Save)))
                {
                    logModel.Status = (int)StatusEnum.Done;
                }
                else
                {
                    logModel.Status = (int)StatusEnum.Checked;
                }
                logModel.OldValue   = JsonConvert.SerializeObject(oldQuestionModel);
                logModel.NewValue   = JsonConvert.SerializeObject(newQuestionModel);
                logModel.UserId     = userId;
                logModel.TargetId   = targetId;
                logModel.Action     = Action;
                logModel.TargetName = TargetName;
                logModel.LogDate    = DateTime.Now;
                logModel.Message    = Message;
                logModel.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
                logModel.Method     = filterContext.ActionDescriptor.ActionName;
                logModel.Fullname   = Fullname;
                logModel.UserCode   = UserCode;
                logger.Log(logModel);
            }

            #region comment

            /*if (!Action.ToLower().Equals("move"))
             * {
             *  logModel.UserId = userId;
             *  logModel.TargetId = targetId;
             *  logModel.Action = Action;
             *  logModel.TargetName = TargetName;
             *  logModel.LogDate = DateTime.Now;
             *  logModel.Message = Message;
             *  logModel.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
             *  logModel.Method = filterContext.ActionDescriptor.ActionName;
             *
             * }
             * else
             * {
             *  logModel.UserId = userId;
             *  logModel.TargetId = targetId;
             *  logModel.Action = Action;
             *  logModel.TargetName = TargetName;
             *  logModel.LogDate = DateTime.Now;
             *  logModel.Message = Message;
             *  logModel.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
             *  logModel.Method = filterContext.ActionDescriptor.ActionName;
             *  logModel.Fullname = Fullname;
             *  logModel.UserCode = UserCode;
             * }*/

            //else
            //{
            //    logModel.OldValue = JsonConvert.SerializeObject(oldQuestionModel);
            //    logModel.NewValue = JsonConvert.SerializeObject(newQuestionModel);
            //    logModel.UserId = userId;
            //    logModel.TargetId = targetId;
            //    logModel.Action = Action;
            //    logModel.TargetName = TargetName;
            //    logModel.LogDate = DateTime.Now;
            //    logModel.Message = Message;
            //    logModel.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            //    logModel.Method = filterContext.ActionDescriptor.ActionName;
            //    logModel.Fullname = Fullname;
            //    logModel.UserCode = UserCode;
            //    logger.Log(logModel);
            //}
            #endregion
        }
Ejemplo n.º 25
0
 public HomeController(QuestionService questionService)
 {
     _questionService = questionService;
 }
Ejemplo n.º 26
0
 public List <UserQuestionDTO> GetQuestions()
 {
     return(QuestionService.GetAllQuestion());
 }
Ejemplo n.º 27
0
 public SubjectsAPIController(dbcontext context)
 {
     fS = new FacultyService(context);
     sS = new SubjectService(context);
     qS = new QuestionService(context);
 }
Ejemplo n.º 28
0
 public UserQuestionDTO GetQuestion(int id)
 {
     return(QuestionService.GetQuestionById(id));
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Initializes process controller
 /// </summary>
 public QuestionController()
 {
     _question = new QuestionService(Data);
 }
Ejemplo n.º 30
0
 public QuestionController(QuestionService service)
 {
     this.service = service;
 }
 public QuestionController()
 {
     questionService = new QuestionService();
 }
Ejemplo n.º 32
0
 public TestController(QuestionService questionService)
 {
     this.questionService = questionService;
 }