Example #1
0
        protected void InitializeDropDowns()
        {
            try
            {
                if (_searchViewModel == null)
                {
                    _searchViewModel = new BaseSearchViewModel();
                }

                _searchViewModel.States            = _da.GetAll <State, STATE>();
                _searchViewModel.Qualifications    = _da.GetModelsBy <QualificationCategory, QUALIFICATION_CATEGORY>(q => q.Qualification_Category_Id >= 3);
                _searchViewModel.TeacherTypes      = _da.GetAll <TeacherType, TEACHER_TYPE>();
                _searchViewModel.StudentCategories = _da.GetAll <StudentCategory, STUDENT_CATEGORY>();

                _searchViewModel.StateSelectList           = DropdownUtility.PopulateModelSelectListHelper(_searchViewModel.States, false, "-- Select Location --");
                _searchViewModel.QualificationSelectList   = DropdownUtility.PopulateModelSelectListHelper(_searchViewModel.Qualifications, false, "-- Select Qualification --");
                _searchViewModel.TeacherTypeSelectList     = DropdownUtility.PopulateModelSelectListHelper(_searchViewModel.TeacherTypes, false, "-- Select Work Mode --");
                _searchViewModel.StudentCategorySelectList = DropdownUtility.PopulateModelSelectListHelper(_searchViewModel.StudentCategories, false, "-- Select Child Category --");

                ViewBag.States            = _searchViewModel.StateSelectList;
                ViewBag.StudentCategories = _searchViewModel.StudentCategorySelectList;
                ViewBag.Qualifications    = _searchViewModel.QualificationSelectList;
                ViewBag.TeacherTypes      = _searchViewModel.TeacherTypeSelectList;

                _searchViewModel.DropdownDataLoaded = true;
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
 private void SetLgaIfExist(State state, Lga lga)
 {
     try
     {
         if (state != null && !string.IsNullOrEmpty(state.Id))
         {
             List <Lga> lgas = _da.GetModelsBy <Lga, LGA>(l => l.State_Id == state.Id);
             if (lga != null && lga.Id > 0)
             {
                 ViewBag.Lgas = new SelectList(lgas, DropdownUtility.ID, DropdownUtility.NAME, lga.Id);
             }
             else
             {
                 ViewBag.Lgas = DropdownUtility.PopulateModelSelectListHelper(lgas, false);
                 //ViewBag.Lgas = new SelectList(lgas, DropdownUtility.ID, DropdownUtility.NAME);
             }
         }
         else
         {
             ViewBag.Lgas = new SelectList(new List <Lga>(), DropdownUtility.ID, DropdownUtility.NAME);
             if (_viewModel.StateSelectList != null && _viewModel.StateSelectList.Count > 0)
             {
                 ViewBag.States = new SelectList(_viewModel.StateSelectList, DropdownUtility.VALUE, DropdownUtility.TEXT, "");
             }
             else
             {
                 ViewBag.States = new SelectList(new List <State>(), DropdownUtility.VALUE, DropdownUtility.NAME);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #3
0
        private void InitializeDropDowns()
        {
            try
            {
                _viewModel.Sexs              = _da.GetAll <Sex, SEX>();
                _viewModel.States            = _da.GetAll <State, STATE>();
                _viewModel.SecurityQuestions = _da.GetAll <SecurityQuestion, SECURITY_QUESTION>();
                _viewModel.TeacherTypes      = _da.GetAll <TeacherType, TEACHER_TYPE>();
                _viewModel.NoOfStudents      = DropdownUtility.CreateNumberListFrom(1, 5);

                _viewModel.SexSelectList              = DropdownUtility.PopulateModelSelectList <Sex, SEX>(_da, false);
                _viewModel.StateSelectList            = DropdownUtility.PopulateModelSelectList <State, STATE>(_da, false);
                _viewModel.CountrySelectList          = DropdownUtility.PopulateModelSelectList <Country, COUNTRY>(_da, false);
                _viewModel.SecurityQuestionSelectList = DropdownUtility.PopulateModelSelectListHelper(_viewModel.SecurityQuestions, "Id", "Question");
                _viewModel.TeacherTypeSelectList      = DropdownUtility.PopulateModelSelectListHelper(_viewModel.TeacherTypes, true);
                _viewModel.NoOfStudentSelectList      = DropdownUtility.PopulateModelSelectListHelper(_viewModel.NoOfStudents, true);

                _viewModel.Periods           = _da.GetAll <Period, PERIOD>();
                _viewModel.WeekDays          = _da.GetAll <WeekDay, WEEK_DAY>();
                _viewModel.StudentCategories = _da.GetAll <StudentCategory, STUDENT_CATEGORY>();

                if (_viewModel.Periods != null && _viewModel.Periods.Count > 0)
                {
                    _viewModel.WeekDays.Insert(0, new WeekDay());
                }
                if (_viewModel.WeekDays != null && _viewModel.WeekDays.Count > 0)
                {
                    _viewModel.Periods.Insert(0, new Period());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex);
                SetMessage(ex.Message, ApplicationMessage.Category.Error);
            }
        }
Example #4
0
        public async Task <ActionResult> Cost(string ptid)
        {
            ServiceCostViewModel viewModel = (ServiceCostViewModel)TempData["TeachingCostViewModel"];

            try
            {
                if (viewModel == null)
                {
                    _viewModel = new ServiceCostViewModel();
                }
                else
                {
                    _viewModel = viewModel;
                }

                if (!string.IsNullOrWhiteSpace(ptid))
                {
                    if (_viewModel.Subscribers == null || _viewModel.Subscribers.Count <= 0)
                    {
                        _viewModel.Subscribers = _da.GetModelsBy <PersonType, PERSON_TYPE>(p => p.Person_Type_Id != 1);
                    }

                    List <PersonType> personTypes = null;
                    if (_viewModel.Subscribers != null && _viewModel.Subscribers.Count > 0)
                    {
                        personTypes = _viewModel.Subscribers.Where(u => ptid.Contains(u.Id.ToString())).ToList();
                        if (personTypes != null && personTypes.Count > 0)
                        {
                            _viewModel.PersonTypeSelectList = DropdownUtility.PopulateModelSelectListHelper(personTypes, false, "-- Select Your Category --");
                            if (personTypes.Count == 1)
                            {
                                ViewBag.PersonTypes = new SelectList(_viewModel.PersonTypeSelectList, DropdownUtility.VALUE, DropdownUtility.TEXT, personTypes[0].Id);
                            }
                            else
                            {
                                ViewBag.PersonTypes = _viewModel.PersonTypeSelectList;
                            }
                        }
                        else
                        {
                            _viewModel.PersonTypeSelectList = new List <SelectListItem>();
                        }
                    }
                    else
                    {
                        _viewModel.PersonTypeSelectList = new List <SelectListItem>();
                    }
                }

                await LoadPersonType();
                await InitializeTeachingCostHelper();
                await InitializeTeacherAvailabilityHelper();

                _viewModel.ServiceCharges = await _da.GetAllAsync <ServiceCharge, SERVICE_CHARGE>();

                _viewModel.TeacherAvailabilities = UiUtility.InitializeAvailability(_viewModel.WeekDays, _viewModel.Periods);
                _viewModel.TeachingCosts         = UiUtility.InitializeTeachingCost(_viewModel.StudentCategories, _viewModel.QualificationCategories, _viewModel.ExistingTeachingCosts);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex);
                SetMessage(ex.Message, ApplicationMessage.Category.Error);
            }

            TempData["TeachingCostViewModel"] = _viewModel;
            return(View(_viewModel));
        }