예제 #1
0
        public ActionResult Edit(ContactLevelInfoModel model)
        {
            try
            {
                model.ContactInfo.Mobile1 = Util.CleanAlphabetAndFirstZero(model.ContactInfo.Mobile1);
                model.ContactInfo.Mobile2 = Util.CleanAlphabetAndFirstZero(model.ContactInfo.Mobile2);
                model.ContactInfo.Mobile3 = Util.CleanAlphabetAndFirstZero(model.ContactInfo.Mobile3);
                var duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(string.Empty, model.ContactInfo.Mobile2, string.Empty, string.Empty, string.Empty, model.ContactInfo.Id);
                if (duplicateId == 0) duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(string.Empty, string.Empty, model.ContactInfo.Mobile3, string.Empty, string.Empty, model.ContactInfo.Id);
                if (duplicateId == 0) duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(string.Empty, string.Empty, string.Empty, model.ContactInfo.Email, string.Empty, model.ContactInfo.Id);
                if (duplicateId == 0) duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(string.Empty, string.Empty, string.Empty, string.Empty, model.ContactInfo.Email2, model.ContactInfo.Id);
                if (duplicateId == 0) duplicateId = ContactRepository.ContactIsDuplicate(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, model.ContactInfo.Mobile3, model.ContactInfo.Email, model.ContactInfo.Email2, model.ContactInfo.Id);
                if (duplicateId > 0 && duplicateId != model.ContactInfo.Id)
                {
                    var contactInfoDb = ContactRepository.GetInfo(duplicateId);
                    if (contactInfoDb == null)
                        ViewBag.Message = "Cập nhật contact bị lỗi do trùng với contact khác trong hệ thống";
                    else
                    {
                        var user = StoreData.ListUser.FirstOrDefault(c => c.UserID == contactInfoDb.UserConsultantId) ??
                                       UserRepository.GetInfo(contactInfoDb.UserConsultantId);

                        ViewBag.Message = user == null
                                              ? "Sđt hoặc Email bạn nhập đã bị trùng với Ứng viên: " + contactInfoDb.Id + " - " + contactInfoDb.Fullname + " - Level " + contactInfoDb.LevelId + " - TVTS: chưa có ai chăm sóc"
                                              : "Sđt hoặc Email bạn nhập đã bị trùng với Ứng viên: " + contactInfoDb.Id + " - " + contactInfoDb.Fullname + " - Level " + contactInfoDb.LevelId + " - TVTS: " + user.FullName;
                    }
                    return Edit(model.ContactInfo.Id, model);
                }

                // Get statusmap
                var statusMapInfo = GetStatusMap(model, EmployeeType.Consultant);
                if (statusMapInfo == null)
                {
                    ViewBag.Message = "Cập nhật contact bị lỗi do không tìm thấy trạng thái chăm sóc";
                    return Edit(model.ContactInfo.Id, model);
                }

                // Delete Redis
                StoreData.DeleteRedis(model.ContactInfo.Id);

                // Update
                var entity = new ContactAllInfo
                                 {
                                     Mobile1 = model.ContactInfo.Mobile1,
                                     Mobile2 = model.ContactInfo.Mobile2,
                                     Mobile3 = model.ContactInfo.Mobile3,
                                     ContactInfo = model.ContactInfo,
                                     ContactLevelInfo = model.ContactLevelInfo,
                                 };
                UpdateContactLevelInfo(entity, model, EmployeeType.Consultant);
                UpdateCallHistoryInfo(entity, model, statusMapInfo, EmployeeType.Consultant);
                UpdateContactInfo(entity, model, statusMapInfo, EmployeeType.Consultant);
                UpdateMissedCallInfo(entity);
                var contactId = ContactAllRepository.Update(entity, EmployeeType.Consultant);
                if (contactId > 0)
                {
                    ViewBag.Close = 1;
                    ViewBag.Message = "Cập nhật contact thành công";

                    // Redis
                    StoreData.LoadRedis(entity.ContactInfo.Id);
                }
                else
                {
                    ViewBag.Close = 0;
                    ViewBag.Message = "Cập nhật contact bị lỗi, vui lòng thử lại sau";

                    // Redis
                    StoreData.DeleteRedis(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, model.ContactInfo.Mobile3, model.ContactInfo.Email, model.ContactInfo.Email2, model.ContactInfo.Id);
                }

                // Repair call
                try
                {
                    StoreData.WsUpdateCallHistoryInfo(entity.CallHistoryInfo.CallHistoryId);
                }
                catch
                {

                }

                // Return
                return Edit(model.ContactInfo.Id, model);
            }
            catch
            {
                ViewBag.Close = 0;
                ViewBag.Message = "Cập nhật contact bị lỗi, vui lòng thử lại sau";

                // Redis
                try
                {
                    StoreData.DeleteRedis(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2,
                        model.ContactInfo.Mobile3, model.ContactInfo.Email, model.ContactInfo.Email2,
                        model.ContactInfo.Id);
                }
                catch
                {

                }
                return Edit(model.ContactInfo.Id, model);
            }
        }
예제 #2
0
        private static void UpdateMissedCallInfo(ContactAllInfo entity)
        {
            if (entity == null ||
               entity.ContactInfo == null ||
               entity.ContactLevelInfo == null)
                return;

            entity.MissedCallInfo = new MissedCallInfo
            {
                Status = 2,
                ContactId = entity.ContactInfo.Id,
            };
        }
예제 #3
0
        private static void UpdateContactLevelInfo(ContactAllInfo entity, ContactLevelInfoModel model, EmployeeType type)
        {
            if (model == null ||
                entity == null ||
                entity.ContactInfo == null ||
                entity.ContactLevelInfo == null)
                return;

            entity.ContactLevelInfo.ContactId = entity.ContactInfo.Id;
            if (!string.IsNullOrEmpty(model.AppointmentTime))
                entity.ContactLevelInfo.AppointmentTime = model.AppointmentTime.ToDateTime();
            switch (type)
            {
                case EmployeeType.Consultant:
                    if (!entity.ContactLevelInfo.HasAppointmentInterview)
                        entity.ContactLevelInfo.HasAppointmentInterview = entity.ContactLevelInfo.HasAppointmentInterviewHidden;
                    if (!entity.ContactLevelInfo.HasPointTestCasec)
                        entity.ContactLevelInfo.HasPointTestCasec = entity.ContactLevelInfo.HasPointTestCasecHidden;
                    if (!entity.ContactLevelInfo.HasPointInterview)
                        entity.ContactLevelInfo.HasPointInterview = entity.ContactLevelInfo.HasPointInterviewHidden;
                    if (!entity.ContactLevelInfo.HasCasecAccount)
                        entity.ContactLevelInfo.HasCasecAccount = entity.ContactLevelInfo.HasCasecAccountHidden;
                    if (!entity.ContactLevelInfo.HasLinkSb100)
                        entity.ContactLevelInfo.HasLinkSb100 = entity.ContactLevelInfo.HasLinkSb100Hidden;
                    if (!entity.ContactLevelInfo.HasSetSb100)
                        entity.ContactLevelInfo.HasSetSb100 = entity.ContactLevelInfo.HasSetSb100Hidden;
                    break;
            }
        }
예제 #4
0
        private static void UpdateContactInfo(ContactAllInfo entity, ContactLevelInfoModel model, StatusMapInfo statusMapInfo, EmployeeType type)
        {
            // Check
            if (model == null || entity == null || entity.ContactInfo == null)
                return;
            if (entity.ContactLevelInfo == null) entity.ContactLevelInfo = new ContactLevelInfo();

            // Get in Db
            entity.ContactInfo = ContactRepository.GetInfo(model.ContactInfo.Id);

            // AppointmentDate
            var datetime = string.IsNullOrEmpty(model.RecallTime) ? string.Empty : model.RecallTime;
            if (!datetime.IsStringNullOrEmpty())
                datetime += string.IsNullOrEmpty(model.RecallTime24h) ? " 00:00:00" : " " + model.RecallTime24h;
            var appointmentDate = string.IsNullOrEmpty(datetime) ? null : datetime.ToDateTime("dd/MM/yyyy HH:mm:ss");

            switch (type)
            {
                case EmployeeType.Collector:
                    break;
                case EmployeeType.Collaborator:
                    entity.ContactInfo.StatusCareCollaboratorId = statusMapInfo.StatusCareId;
                    entity.ContactInfo.CallCollaboratorDate = entity.CallHistoryInfo.CallTime;
                    entity.ContactInfo.CallInfoCollaborator = model.ContactInfo.CallInfoCollaborator;
                    entity.ContactInfo.StatusMapCollaboratorId = model.ContactInfo.StatusMapCollaboratorId;
                    entity.ContactInfo.CallCount = entity.ContactInfo.StatusCareCollaboratorId == (int)StatusCareType.UnKnown
                                        ? entity.ContactInfo.CallCount + 1
                                        : 0;
                    entity.ContactInfo.AppointmentCollaboratorDate = appointmentDate;
                    break;
                case EmployeeType.Consultant:
                    entity.ContactInfo.StatusCareConsultantId = statusMapInfo.StatusCareId;
                    entity.ContactInfo.CallConsultantDate = entity.CallHistoryInfo.CallTime;
                    entity.ContactInfo.CallInfoConsultant = model.ContactInfo.CallInfoConsultant;
                    entity.ContactInfo.StatusMapConsultantId = model.ContactInfo.StatusMapConsultantId;
                    entity.ContactInfo.CallCount = entity.ContactInfo.StatusCareConsultantId == (int)StatusCareType.UnKnown
                                        ? entity.ContactInfo.CallCount + 1
                                        : 0;
                    entity.ContactInfo.AppointmentConsultantDate = appointmentDate;
                    entity.ContactInfo.ProductSoldId = model.ContactInfo.ProductSoldId;
                    break;
            }
            entity.ContactInfo.Id = model.ContactInfo.Id;
            entity.ContactInfo.Email = model.ContactInfo.Email;
            entity.ContactInfo.Notes = model.ContactInfo.Notes;
            entity.ContactInfo.Email2 = model.ContactInfo.Email2;
            entity.ContactInfo.Gender = model.ContactInfo.Gender;
            entity.ContactInfo.Address = model.ContactInfo.Address;
            entity.ContactInfo.StatusId = statusMapInfo.StatusIdNext;
            entity.ContactInfo.Fullname = model.ContactInfo.Fullname;
            entity.ContactInfo.Birthday = model.Birthday.ToDateTime();
            entity.ContactInfo.CallCount = model.ContactInfo.CallCount;
            entity.ContactInfo.QualityId = model.ContactInfo.QualityId;
            entity.ContactInfo.ProductSellId = model.ContactInfo.ProductSellId;
            entity.ContactInfo.CreatedBy = UserContext.GetCurrentUser().UserID;
            if (statusMapInfo.LevelIdNext > 0) entity.ContactInfo.LevelId = statusMapInfo.LevelIdNext;
            entity.ContactInfo.HandoverHistoryConsultantId = model.ContactInfo.HandoverHistoryConsultantId;
        }
예제 #5
0
        private static void UpdateCallHistoryInfo(ContactAllInfo entity, ContactLevelInfoModel model, StatusMapInfo statusMapInfo, EmployeeType type)
        {
            if (model == null || entity == null || entity.ContactInfo == null)
                return;
            if (entity.ContactLevelInfo == null) entity.ContactLevelInfo = new ContactLevelInfo();

            var user = UserContext.GetCurrentUser();

            // Datetime
            var datetime = string.IsNullOrEmpty(model.RecallTime)
                               ? DateTime.Now.ToString("dd/MM/yyyy")
                               : model.RecallTime;
            datetime += string.IsNullOrEmpty(model.RecallTime24h)
                            ? " 00:00:00"
                            : " " + model.RecallTime24h;

            // CallInfo
            var callInfo = string.Empty;
            switch (type)
            {
                case EmployeeType.Collector:
                    break;
                case EmployeeType.Collaborator:
                    callInfo = model.ContactInfo.CallInfoCollaborator;
                    break;
                case EmployeeType.Consultant:
                    callInfo = model.ContactInfo.CallInfoConsultant;
                    break;
            }
            entity.CallHistoryInfo = new CallHistoryInfo
                                         {
                                             StatusUpdate = 1,
                                             UserLogType = (int)type,
                                             CreatedBy = user.UserID,
                                             CallTime = DateTime.Now,
                                             CallCenterInfo = callInfo,
                                             CreatedDate = DateTime.Now,
                                             StatusMapId = statusMapInfo.Id,
                                             ContactId = model.ContactInfo.Id,
                                             CallType = (int)CallType.Outcoming,
                                             LevelId = statusMapInfo.LevelIdNext,
                                             CallHistoryId = model.CallHistoryId,
                                             StatusCareId = statusMapInfo.StatusCareId,
                                             RecallTime = datetime.ToDateTime("dd/MM/yyyy HH:mm:ss"),
                                         };
        }
예제 #6
0
 public static int Update(ContactAllInfo info, EmployeeType type)
 {
     if (info.Mobile1.StartsWith("0")) info.Mobile1 = info.Mobile1.Substring(1);
     if (info.Mobile2.StartsWith("0")) info.Mobile2 = info.Mobile2.Substring(1);
     if (info.Mobile3.StartsWith("0")) info.Mobile3 = info.Mobile3.Substring(1);
     switch (type)
     {
         case EmployeeType.Collaborator:
             return DataProvider.Instance().Contacts_Update_Care_Collaborator(info.ContactInfo.Id,
                 info.ContactInfo.Fullname,
                 info.ContactInfo.Address,
                 info.ContactInfo.Birthday,
                 info.ContactInfo.Gender,
                 info.ContactInfo.Email,
                 info.ContactInfo.Email2,
                 info.ContactInfo.Notes,
                 info.ContactInfo.AppointmentCollaboratorDate,
                 info.ContactInfo.CallCollaboratorDate,
                 info.ContactInfo.LevelId,
                 info.ContactInfo.StatusId,
                 info.ContactInfo.StatusMapCollaboratorId,
                 info.ContactInfo.StatusCareCollaboratorId,
                 info.ContactInfo.CallInfoCollaborator,
                 info.ContactInfo.CallCount,
                 info.ContactInfo.HandoverHistoryCollaboratorId,
                 info.ContactInfo.QualityId,
                 info.ContactLevelInfo.WantStudyEnglish,
                 info.ContactLevelInfo.HasAppointment,
                 info.ContactLevelInfo.AppointmentTime,
                 info.ContactLevelInfo.ApointmentType,
                 info.ContactLevelInfo.ApointmentNotes,
                 info.CallHistoryInfo.CallHistoryId,
                 info.CallHistoryInfo.StatusUpdate,
                 info.CallHistoryInfo.CallType,
                 info.CallHistoryInfo.UserLogType,
                 info.Mobile1,
                 info.Mobile2,
                 info.Mobile3,
                 info.MissedCallInfo.Status,
                 info.ContactInfo.CreatedBy);
         case EmployeeType.Consultant:
             return DataProvider.Instance().Contacts_Update_Care_Consultant(info.ContactInfo.Id,
                 info.ContactInfo.Fullname,
                 info.ContactInfo.Address,
                 info.ContactInfo.Birthday,
                 info.ContactInfo.Gender,
                 info.ContactInfo.Email,
                 info.ContactInfo.Email2,
                 info.ContactInfo.Notes,
                 info.ContactInfo.AppointmentConsultantDate,
                 info.ContactInfo.CallConsultantDate,
                 info.ContactInfo.LevelId,
                 info.ContactInfo.StatusId,
                 info.ContactInfo.StatusMapConsultantId,
                 info.ContactInfo.StatusCareConsultantId,
                 info.ContactInfo.CallInfoConsultant,
                 info.ContactInfo.CallCount,
                 info.ContactInfo.ProductSellId,
                 info.ContactInfo.ProductSoldId,
                 info.ContactInfo.HandoverHistoryConsultantId,
                 info.ContactInfo.QualityId,
                 info.ContactLevelInfo.EducationSchoolName,
                 info.ContactLevelInfo.WantStudyEnglish,
                 info.ContactLevelInfo.HasAppointment,
                 info.ContactLevelInfo.AppointmentTime,
                 info.ContactLevelInfo.ApointmentType,
                 info.ContactLevelInfo.ApointmentNotes,
                 info.ContactLevelInfo.HasAppointmentInterview,
                 info.ContactLevelInfo.AppointmentInterviewId,
                 info.ContactLevelInfo.HasCasecAccount,
                 info.ContactLevelInfo.HasPointTestCasec,
                 info.ContactLevelInfo.HasPointInterview,
                 info.ContactLevelInfo.HasSetSb100,
                 info.ContactLevelInfo.HasLinkSb100,
                 info.ContactLevelInfo.FeePackageType,
                 info.ContactLevelInfo.FeeTuitionType,
                 info.ContactLevelInfo.FeeMoneyType,
                 info.ContactLevelInfo.FeeEdu,
                 info.ContactLevelInfo.FeeEduYet,
                 info.ContactLevelInfo.FeeEduNotes,
                 info.CallHistoryInfo.CallHistoryId,
                 info.CallHistoryInfo.StatusUpdate,
                 info.CallHistoryInfo.CallType,
                 info.CallHistoryInfo.UserLogType,
                 info.Mobile1,
                 info.Mobile2,
                 info.Mobile3,
                 info.MissedCallInfo.Status,
                 info.ContactInfo.CreatedBy);
     }
     return 0;
 }