private ContactLevelInfoModel InitModel(ContactInfo contactInfo, ContactLevelInfo contactLevelInfo)
        {
            var model = new ContactLevelInfoModel
            {
                ContactInfo = contactInfo,
                ContactLevelInfo = contactLevelInfo,
            };
            if (model.ContactLevelInfo != null)
            {
                // AppointmentTime
                if (model.ContactLevelInfo.AppointmentTime != null)
                    model.AppointmentTime = model.ContactLevelInfo.AppointmentTime.Value.ToString("dd/MM/yyyy");

                // CasecAccountInfo
                var casecAccounts = CasecAccountRepository.GetAllByContactId(contactLevelInfo.ContactId) ?? new List<CasecAccountInfo>();
                model.CasecAccountInfo = casecAccounts.FirstOrDefault(c => c.StatusCasecAccountId == (int)StatusCasecType.Used);
                model.ContactLevelInfo.HasCasecAccount = model.CasecAccountInfo != null;
                model.ContactLevelInfo.HasCasecAccountHidden = model.ContactLevelInfo.HasCasecAccount;

                // TestResultCasecInfo
                model.TestResultCasecInfo = TestResultRepository.GetResultCasecCurent(contactLevelInfo.ContactId);
                if (model.TestResultCasecInfo != null)
                {
                    if (model.TestResultCasecInfo.FullName.IsStringNullOrEmpty())
                        model.TestResultCasecInfo.FullName = model.ContactInfo.Fullname;
                    model.ContactLevelInfo.HasPointTestCasec = true;
                    var casecAccount = casecAccounts.FirstOrDefault(c => c.Id == model.TestResultCasecInfo.CasecAccountId) ?? new CasecAccountInfo();
                    model.TestResultCasecInfo.Account = casecAccount.Account;
                    model.TestResultCasecInfo.Password = casecAccount.Password;
                }
                else model.ContactLevelInfo.HasPointTestCasec = false;
                model.ContactLevelInfo.HasPointTestCasecHidden = model.ContactLevelInfo.HasPointTestCasec;

                // TestResultInterviewInfo
                model.TestResultInterviewInfo = TestResultRepository.GetResultInterviewCurent(contactLevelInfo.ContactId);
                if (model.TestResultInterviewInfo != null)
                {
                    if (model.TestResultInterviewInfo.FullName.IsStringNullOrEmpty())
                        model.TestResultInterviewInfo.FullName = model.ContactInfo.Fullname;
                    model.ContactLevelInfo.HasPointInterview = true;
                }
                else model.ContactLevelInfo.HasPointInterview = false;
                model.ContactLevelInfo.HasPointInterviewHidden = model.ContactLevelInfo.HasPointInterview;

                // TestResultLinkSb100Info
                model.TestResultLinkSb100Info = TestResultRepository.GetResultLinkSb100Curent(contactLevelInfo.ContactId);
                if (model.TestResultLinkSb100Info != null)
                {
                    if (model.TestResultLinkSb100Info.FullName.IsStringNullOrEmpty())
                        model.TestResultLinkSb100Info.FullName = model.ContactInfo.Fullname;
                    model.ContactLevelInfo.HasLinkSb100 = true;
                }
                else model.ContactLevelInfo.HasLinkSb100 = false;
                model.ContactLevelInfo.HasLinkSb100Hidden = model.ContactLevelInfo.HasLinkSb100;

                // AppointmentInterviewInfo
                model.AppointmentInterviewInfo = AppointmentInterviewRepository.GetInfo(contactLevelInfo.ContactId);
                model.ContactLevelInfo.HasAppointmentInterview = model.AppointmentInterviewInfo != null;
                //if (model.AppointmentInterviewInfo != null &&
                //    model.AppointmentInterviewInfo.StatusInterviewId == (int)StatusInterviewType.HocVienHuyPhongVan)
                //{
                //    model.AppointmentInterviewInfo = null;
                //    model.ContactLevelInfo.HasAppointmentInterview = false;
                //}
                model.ContactLevelInfo.HasAppointmentInterviewHidden = model.ContactLevelInfo.HasAppointmentInterview;

                // SB100
                model.ContactLevelInfo.HasSetSb100Hidden = model.ContactLevelInfo.HasSetSb100;
            }

            if (model.ContactInfo != null)
            {
                // Phone
                var listPhone = PhoneRepository.GetByContact(contactInfo.Id);
                if (listPhone != null)
                {
                    model.ContactInfo.Mobile1 = listPhone.Count > 0 ? listPhone[0].PhoneNumber : string.Empty;
                    model.ContactInfo.Mobile2 = listPhone.Count > 1 ? listPhone[1].PhoneNumber : string.Empty;
                    model.ContactInfo.Mobile3 = listPhone.Count > 2 ? listPhone[2].PhoneNumber : string.Empty;
                }

                // Birthday
                if (model.ContactInfo.Birthday != null)
                    model.Birthday = model.ContactInfo.Birthday.Value.ToString("dd/MM/yyyy");
            }
            else model.ContactInfo = new ContactInfo();

            // StatusMaps
            List<StatusMapInfo> statusMaps;
            if (StoreData.ListStatusMap != null && StoreData.ListStatusMap.Count > 0)
            {
                statusMaps = model.ContactInfo == null
                                     ? StoreData.ListStatusMap
                                     : StoreData.ListStatusMap.Where(c => c.LevelId == model.ContactInfo.LevelId).ToList();
            }
            else
            {
                statusMaps = model.ContactInfo == null
                                         ? StatusMapRepository.GetAll()
                                         : StatusMapRepository.GetAllByLevelId(model.ContactInfo.LevelId);
            }
            ViewBag.StatusMaps = statusMaps != null && statusMaps.Count > 0
                                     ? statusMaps.Where(c => c.StatusMapType == (int)EmployeeType.Consultant).ToList()
                                     : new List<StatusMapInfo>();
            return model;
        }
 public static int UpdateInsertTvts(ContactLevelInfo info)
 {
     return DataProvider.Instance().ContactLevelInfos_Update_InsertTvts(info.ContactId);
 }
        private static List<ContactLevelInfo> FillContactLevelInfoCollection(IDataReader reader, out int totalRecords)
        {
            var retVal = new List<ContactLevelInfo>();
            totalRecords = 0;
            try
            {
                while (reader.Read())
                {
                    //fill business object
                    var info = new ContactLevelInfo
                                   {
                                       ContactId = ConvertHelper.ToInt32(reader["ContactId"]),
                                       EducationSchoolName = ConvertHelper.ToString(reader["EducationLevelNotes"]),
                                       WantStudyEnglish = ConvertHelper.ToBoolean(reader["WantStudy"]),
                                       HasAppointment = ConvertHelper.ToBoolean(reader["Appointment"]),
                                       ApointmentType = ConvertHelper.ToInt32(reader["ApointmentType"]),
                                       ApointmentNotes = ConvertHelper.ToString(reader["ApointmentNotes"]),
                                   };
                    retVal.Add(info);
                }
                //Get the next result (containing the total)
                reader.NextResult();

                //Get the total no of records from the second result
                if (reader.Read())
                {
                    totalRecords = Convert.ToInt32(reader[0]);
                }

            }
            catch
            {
                //DotNetNuke.Services.Exceptions.Exceptions.LogException(exc);
            }
            finally
            {
                //close datareader
                ObjectHelper.CloseDataReader(reader, true);
            }
            return retVal;
        }
 public static int Update(ContactLevelInfo info)
 {
     return 1;
     //return DataProvider.Instance().ContactLevelInfos_Update(info.ContactId, info.HaveJob, info.JobTitle, info.EducationLevelId, info.EducationSchoolName, info.CalledDate, info.CollaboratorName, info.SchoolName, info.WantStudyEnglish, info.WantStudyNotes, info.Majors, info.HasAppointment, info.AppointmentTime, info.ApointmentType, info.ApointmentNotes, info.SubmitedForm, info.SubmitedFormNotes, info.FeeReview, info.FeeReviewTime, info.FeeReviewNotes, info.AcceptedReview, info.AcceptedReviewNotes, info.FeeEdu, info.FeeEduNotes, info.SubmitedProfile, info.SubmitedProfileType, info.SubmitedProfileNotes, info.LumpedAdmissionId, info.Completed, info.CompletedTime, info.CompletedNotes, info.LumpedCareId, info.LumpedFeeId, info.LatchId, info.SchoolGrad, info.MajorGrad, info.HaveLearnTransfer);
 }