public async Task GetShouldNotFailTest()
        {
            var sut      = new StatusMapRepository(new AmsContext(Options));
            var statuses = await sut.GetShouldNotFail();

            Assert.IsTrue(statuses.Any());
        }
        public async Task GetForcingCastEnumTest()
        {
            var sut      = new StatusMapRepository(new AmsContext(Options));
            var statuses = await sut.GetForcingCastEnum();

            Assert.IsTrue(statuses.Any());
        }
Example #3
0
        public IEnumerable <StatusMapInfo> GetByStatusCareId(int statusCareId, int employeeTypeId)
        {
            var list = StatusMapRepository.GetAll() ?? new List <StatusMapInfo>();

            list = list
                   .Where(c => c.StatusCareId == statusCareId)
                   .Where(c => c.StatusMapType == employeeTypeId)
                   .ToList();
            list.Insert(0, new StatusMapInfo
            {
                Id   = 0,
                Name = "Tất cả",
            });
            return(list);
        }
Example #4
0
        public ActionResult FilterContactHandover()
        {
            // Check account user form
            var status = StoreData.CheckAccountUseHandover(EmployeeType.Consultant);

            // ImportExcelCCs
            var importExcels = ImportExcelRepository.FilterForCampain(UserContext.GetDefaultBranch(), (int)SourceType.CC);

            foreach (var item in importExcels)
            {
                item.FilePath = (new FileInfo(item.FilePath)).Name;
            }
            ViewBag.Channels       = ChannelRepository.GetAll();
            ViewBag.ImportExcelCCs = importExcels;
            ViewBag.StatusMessage  = status;
            ViewBag.StatusCares    = StatusCareRepository.GetAll();
            ViewBag.StatusMaps     = StatusMapRepository.GetAll();

            return(View(new ContactCreateModel()));
        }
Example #5
0
        public IEnumerable <StatusMapInfo> GetByStatusCareAndLevel(int statusCareId, string levelIds, int employeeTypeId)
        {
            var list = StatusMapRepository.GetAll() ?? new List <StatusMapInfo>();

            levelIds = levelIds.IsStringNullOrEmpty() ? "0" : levelIds;
            var arrLevelId = levelIds.Split(',').Select(c => c.ToInt32()).ToList();

            arrLevelId.RemoveAll(c => c.Equals(0));

            list = list
                   .Where(c => c.StatusCareId == statusCareId)
                   .Where(c => c.StatusMapType == employeeTypeId)
                   .ToList();
            if (!arrLevelId.IsNullOrEmpty())
            {
                list = list.Where(c => arrLevelId.Any(p => p == c.LevelId)).ToList();
            }
            list.Insert(0, new StatusMapInfo
            {
                Id   = 0,
                Name = "Tất cả",
            });
            return(list);
        }
Example #6
0
        public static T Create <T>(ContactInfo info) where T : BCModelContact
        {
            var objModel = Activator.CreateInstance(typeof(T)) as BCModelContact;

            if (objModel == null)
            {
                return(default(T));
            }

            objModel.Id           = info.Id;
            objModel.Code         = info.Code;
            objModel.Email        = info.Email;
            objModel.Location     = info.Address;
            objModel.Fullname     = info.Fullname;
            objModel.Level        = Enum.GetName(typeof(LevelType), info.LevelId);
            objModel.SourceType   = Enum.GetName(typeof(SourceType), info.TypeId);
            objModel.HandoverDate = info.HandoverConsultantDate != null
                ? info.HandoverConsultantDate.Value.ToString("dd/MM/yyyy")
                : string.Empty;

            objModel.HandoverDistributorDate = info.HandoverCollaboratorDate != null
                ? info.HandoverCollaboratorDate.Value.ToString("dd/MM/yyyy")
                : info.RegisteredDate != null?info.RegisteredDate.Value.ToString("dd/MM/yyyy") : string.Empty;

            // Phone
            var phones = PhoneRepository.GetByContact(info.Id);

            if (phones != null)
            {
                var phoneEntity = phones.FirstOrDefault(phone => phone.IsPrimary > 0) ?? phones.FirstOrDefault();
                if (phoneEntity != null)
                {
                    objModel.Mobile = phoneEntity.PhoneNumber;
                }
            }

            // StatusCare
            var statusCare = StatusCareRepository.GetAll().FirstOrDefault(c => c.Id == info.StatusCareConsultantId);

            if (statusCare != null)
            {
                objModel.StatusCare = statusCare.Name;
            }

            // StatusMap
            var statusMap = StatusMapRepository.GetAll().FirstOrDefault(c => c.Id == info.StatusMapConsultantId) ??
                            StatusMapRepository.GetInfo(info.StatusMapConsultantId);

            if (statusMap != null)
            {
                objModel.StatusMap = statusMap.Name;
            }

            // Notes
            if (info.CallInfoConsultant.IsStringNullOrEmpty())
            {
                var callHistories = CallHistoryRepository.GetAllByContactId(info.Id);
                if (!callHistories.IsNullOrEmpty())
                {
                    objModel.Notes = callHistories.Last().CallCenterInfo;
                }
            }
            else
            {
                objModel.Notes = info.CallInfoConsultant;
            }

            // Channel
            if (objModel.SourceType == Enum.GetName(typeof(SourceType), Core.SourceType.MO))
            {
                var channel = ChannelRepository.GetAll().FirstOrDefault(c => c.ChannelId == info.ChannelId) ??
                              ChannelRepository.GetInfo(info.ChannelId);
                if (channel != null)
                {
                    objModel.Channel = channel.Name;
                }
            }
            else if (objModel.SourceType == Enum.GetName(typeof(SourceType), Core.SourceType.CC))
            {
                if (info.UserCollaboratorId > 0)
                {
                    var user = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserCollaboratorId);
                    if (user != null)
                    {
                        objModel.Channel = user.FullName;
                    }
                }
            }
            else
            {
                if (info.ChannelId == 1)
                {
                    if (info.UserCollaboratorId > 0)
                    {
                        var user = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserCollaboratorId);
                        if (user != null)
                        {
                            objModel.Channel = user.FullName;
                        }
                    }
                }
                if (objModel.Channel.IsStringNullOrEmpty())
                {
                    var channel = ChannelRepository.GetAll().FirstOrDefault(c => c.ChannelId == info.ChannelId) ??
                                  ChannelRepository.GetInfo(info.ChannelId);
                    if (channel != null)
                    {
                        objModel.Channel = channel.Name;
                    }
                }
            }

            // Consultant
            var consultant = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserConsultantId) ??
                             UserRepository.GetInfo(info.UserConsultantId);

            if (consultant != null)
            {
                objModel.Consultant = consultant.FullName;
            }

            return((T)objModel);
        }
Example #7
0
        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");
                }
            }

            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>();
            // 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;

            // TopicaAccountInfo
            var topicaAccounts = TopicaAccountRepository.GetAllByContactId(contactLevelInfo.ContactId) ?? new List <TopicaAccountInfo>();

            model.TopicaAccountInfo = topicaAccounts.FirstOrDefault(c => c.StatusTopicaAccountId == (int)StatusTopicaType.Used);
            model.ContactLevelInfo.HasTopicaAccount      = model.TopicaAccountInfo != null;
            model.ContactLevelInfo.HasCasecAccountHidden = model.ContactLevelInfo.HasTopicaAccount;

            // TestResultCasecInfo
            model.TestResultCasecInfo = TestResultRepository.GetResultCasecCurent(contactLevelInfo.ContactId);
            if (model.TestResultCasecInfo != null)
            {
                if (model.TestResultCasecInfo.FullName == null || model.TestResultCasecInfo.FullName == "")
                {
                    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;

            // TestResultTopicaInfo
            model.TestResultTopicaInfo = TestResultRepository.GetResultTopicaCurent(contactLevelInfo.ContactId);
            if (model.TestResultTopicaInfo != null)
            {
                if (model.TestResultTopicaInfo.FullName == null || model.TestResultTopicaInfo.FullName == "")
                {
                    model.TestResultTopicaInfo.FullName = model.ContactInfo.Fullname;
                }
                model.ContactLevelInfo.HasPointTestTopica = true;
                var topicaAccount = topicaAccounts.FirstOrDefault(c => c.Account == model.TestResultTopicaInfo.Account) ?? new TopicaAccountInfo();
                model.TestResultTopicaInfo.Account  = topicaAccount.Account;
                model.TestResultTopicaInfo.Password = topicaAccount.Password;
            }
            else
            {
                model.ContactLevelInfo.HasPointTestTopica = false;
            }
            model.ContactLevelInfo.HasPointTestCasecHidden = model.ContactLevelInfo.HasPointTestTopica;

            // TestResultInterviewInfo
            model.TestResultInterviewInfo = TestResultRepository.GetResultInterviewCurent(contactLevelInfo.ContactId);
            if (model.TestResultInterviewInfo != null)
            {
                if (model.TestResultInterviewInfo.FullName == null || model.TestResultInterviewInfo.FullName == "")
                {
                    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);

            return(model);
        }
Example #8
0
 // GET api/<controller>
 public IEnumerable <StatusMapInfo> Get()
 {
     return(StatusMapRepository.GetAll());
 }