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)); }