public static int LogCreateContactTvts(ContactInfo entity) { try { var log = new ActivityLogInfo { FunctionId = entity.Id, CreatedBy = UserRepository.GetCurrentUserInfo().UserID, FunctionType = (int)LogFunctionType.CreateContactTvts, }; log.Id = Create(log); LogObjectChange(entity, log, LogPropertyType.Contacts_StatusMap_Consultant, LogPropertyType.Contacts_StatusCare_Consultant, LogPropertyType.Contacts_Level, LogPropertyType.Contacts_Type, LogPropertyType.Contacts_Channel, LogPropertyType.Contacts_Branch, LogPropertyType.Contacts_Status, LogPropertyType.Contacts_User_Consultant, LogPropertyType.Contacts_HandoverDate_Consultant, LogPropertyType.Contacts_AppointmentDate_Consultant); return log.Id; } catch { } return 0; }
public static void UpdateImportProgress(ImportExcelInfo import, ContactInfo contact, string mobile1, string mobile2, string tel) { if (contact == null) { Update(import); } else { DataProvider.Instance().ImportExcels_UpdateImportProgress(import.ImportId, import.RowIndex, import.TotalRow, import.CheckCount, import.ErrorCount, import.InternalDuplicateCount, import.DuplicateCount, contact.Code, contact.Fullname, contact.Birthday, contact.Email, mobile1, mobile2, tel, contact.Address, contact.Gender, contact.TypeId, contact.ChannelId, contact.LevelId, contact.CollectorId, contact.BranchId, contact.StatusId, contact.StatusCareConsultantId, contact.RegisteredDate, contact.Notes); } }
public static BC10Model CreateBc10Model(ContactInfo info) { var objModel = Create<BC10Model>(info); // Collaborator var collaborator = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserCollaboratorId); if (collaborator != null) objModel.Collaborator = collaborator.FullName; var channel = StoreData.ListChannel.FirstOrDefault(c => c.ChannelId == info.ChannelId); if (channel != null) objModel.Channel = channel.Name; objModel.Code = info.Code; return objModel; }
public ContactAddModel() { ContactInfo = new ContactInfo { Fullname = string.Empty, Mobile1 = string.Empty, Mobile2 = string.Empty, Email = string.Empty, Email2 = string.Empty, Birthday = null, Address = string.Empty, Notes = string.Empty, ProductSellId = 0, }; }
public static int LogCareContact(ContactInfo entity, params LogPropertyType[] types) { try { var log = new ActivityLogInfo { FunctionId = entity.Id, FunctionType = (int)LogFunctionType.CareContactConsultant, CreatedBy = UserRepository.GetCurrentUserInfo().UserID, }; log.Id = Create(log); LogObjectChange(entity, log, types); return log.Id; } catch { } return 0; }
public static int CreateTvts(ContactInfo info) { return DataProvider.Instance().Contacts_Insert_Tvts( info.Email, info.Email2, info.LevelId, info.Birthday, info.TypeId, info.Gender, info.Fullname, info.Address, info.Notes, info.BranchId, info.ProductSellId, info.StatusId, info.UserConsultantId, info.StatusMapConsultantId, info.StatusCareConsultantId, info.RegisteredDate, info.CreatedDate, info.HandoverConsultantDate, info.AppointmentConsultantDate, info.Mobile1, info.Mobile2, info.CreatedBy); }
// Create public static int CreateTmp(ContactInfo info) { return DataProvider.Instance().Contacts_Insert_Tmp( info.Code, info.Fullname, info.Address, info.Birthday, info.Gender, info.Email, info.Email2, info.Notes, info.RegisteredDate, info.CreatedDate, info.ImportedDate, info.CollectorId, info.TypeId, info.ChannelId, info.CampaindTpeId, info.LandingPageId, info.TemplateAdsId, info.SearchKeywordId, info.PackageId, info.LevelId, info.BranchId, info.StatusId, info.ImportId, info.ContainerId, info.UserImportId, info.UserErrorId, info.Mobile1, info.Mobile2, info.Mobile3, info.CreatedBy); }
public static int CreateHv(ContactInfo info) { return DataProvider.Instance().Contacts_Insert_Hv(info.Email, info.Email2, info.LevelId, info.Birthday, info.TypeId, info.Gender, info.Fullname, info.ChannelId, info.BranchId, info.CollectorId, info.StatusId, info.UserConsultantId, info.StatusMapConsultantId, info.StatusCareConsultantId, info.RegisteredDate, info.CreatedDate, info.HandoverConsultantDate, info.AppointmentConsultantDate, info.Mobile1, info.Mobile2, info.CreatedBy); }
public static int Create(ContactInfo info) { return DataProvider.Instance().Contacts_Insert(info.Code, info.Fullname, info.Birthday, info.Email, info.Address, info.Gender, info.TypeId, info.ChannelId, info.LevelId, info.CollectorId, info.BranchId, info.StatusId, info.StatusCareConsultantId, info.RegisteredDate, info.Notes, info.ImportId); }
// Update public static void ContactUpdateL1(ContactInfo info) { DataProvider.Instance().Contacts_Update_L1(info.Id, info.Fullname, info.Birthday, info.Email, info.Email2, info.Address, info.Gender, info.ProductSellId, info.Notes, info.Mobile1, info.Mobile2, info.Mobile3); }
public static void ContactsAcceptL1(ContactInfo entity, string pageCode, int createdBy) { }
private static ContactRecoveryInfo CreateContactRecoveryInfo(ContactInfo info, EmployeeType employeeType) { var objModel = new ContactRecoveryInfo { Id = info.Id, Email = info.Email, Fullname = info.Fullname, LocationName = info.Address, Level = Enum.GetName(typeof(LevelType), info.LevelId), SourceTypeName = Enum.GetName(typeof(SourceType), info.TypeId), RegisteredDate = info.RegisteredDate != null ? info.RegisteredDate.Value.ToString("dd/MM/yyyy") : string.Empty, UserName = info.UserName, StatusCare = info.StatusCare, StatusMap = info.StatusMap, }; switch (employeeType) { case EmployeeType.Collaborator: { objModel.HandoverDate = info.HandoverCollaboratorDate != null ? info.HandoverCollaboratorDate.Value.ToString("dd/MM/yyyy") : string.Empty; // StatusCare var statusCare = StoreData.ListStatusCare.FirstOrDefault(c => c.Id == info.StatusCareCollaboratorId); if (statusCare != null) objModel.StatusCare = statusCare.Name; // StatusMap var statusMap = StoreData.ListStatusMap.FirstOrDefault(c => c.Id == info.StatusMapCollaboratorId) ?? StatusMapRepository.GetInfo(info.StatusMapCollaboratorId); if (statusMap != null) objModel.StatusMap = statusMap.Name; // Notes if (info.CallInfoCollaborator.IsStringNullOrEmpty()) { var callHistories = CallHistoryRepository.GetAllByContactId(info.Id); if (!callHistories.IsNullOrEmpty()) if (!callHistories.IsNullOrEmpty()) { var callHistory = callHistories.LastOrDefault(c => c.UserLogType == (int)employeeType) ?? new CallHistoryInfo(); objModel.Notes = callHistory.CallCenterInfo; } } else objModel.Notes = info.CallInfoCollaborator; // Collaborator var consultant = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserCollaboratorId) ?? UserRepository.GetInfo(info.UserCollaboratorId); if (consultant != null) objModel.UserName = consultant.FullName; } break; case EmployeeType.Consultant: { objModel.HandoverDate = info.HandoverConsultantDate != null ? info.HandoverConsultantDate.Value.ToString("dd/MM/yyyy") : string.Empty; // StatusCare var statusCare = StoreData.ListStatusCare.FirstOrDefault(c => c.Id == info.StatusCareConsultantId); if (statusCare != null) objModel.StatusCare = statusCare.Name; // StatusMap var statusMap = StoreData.ListStatusMap.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()) { var callHistory = callHistories.LastOrDefault(c => c.UserLogType == (int)employeeType) ?? new CallHistoryInfo(); objModel.Notes = callHistory.CallCenterInfo; } } else objModel.Notes = info.CallInfoConsultant; // Consultant var consultant = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserConsultantId) ?? UserRepository.GetInfo(info.UserConsultantId); if (consultant != null) objModel.UserName = consultant.FullName; } break; } // 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; } // Channel if (objModel.SourceTypeName == Enum.GetName(typeof(SourceType), SourceType.MO)) { var channel = StoreData.ListChannel.FirstOrDefault(c => c.ChannelId == info.ChannelId) ?? ChannelRepository.GetInfo(info.ChannelId); if (channel != null) objModel.ChannelName = channel.Name; } else if (objModel.SourceTypeName == Enum.GetName(typeof(SourceType), SourceType.CC)) { } else { if (objModel.ChannelName.IsStringNullOrEmpty()) { var channel = StoreData.ListChannel.FirstOrDefault(c => c.ChannelId == info.ChannelId) ?? ChannelRepository.GetInfo(info.ChannelId); if (channel != null) objModel.ChannelName = channel.Name; } } return objModel; }
private static void LogObjectChange(ContactInfo entity, ActivityLogInfo log, params LogPropertyType[] types) { foreach (var type in types) { var logObject = new ActivityObjectChangeInfo { ActivityId = log.Id, ObjectId = entity.Id, PropertyType = (int)type, ObjectType = (int)LogObjectType.Contact, }; switch (type) { case LogPropertyType.Contacts_User_Consultant: logObject.PropertyValueInt = entity.UserConsultantId; break; case LogPropertyType.Contacts_Type: logObject.PropertyValueInt = entity.TypeId; break; case LogPropertyType.Contacts_Level: logObject.PropertyValueInt = entity.LevelId; break; case LogPropertyType.Contacts_Channel: logObject.PropertyValueInt = entity.ChannelId; break; case LogPropertyType.Contacts_Branch: logObject.PropertyValueInt = entity.BranchId; break; case LogPropertyType.Contacts_Status: logObject.PropertyValueInt = entity.StatusId; break; case LogPropertyType.Contacts_AppointmentDate_Consultant: logObject.PropertyValueDateTime = entity.AppointmentConsultantDate; break; case LogPropertyType.Contacts_HandoverDate_Consultant: logObject.PropertyValueDateTime = entity.HandoverConsultantDate; break; case LogPropertyType.Contacts_CallDate_Consultant: logObject.PropertyValueDateTime = entity.CallConsultantDate; break; case LogPropertyType.Contacts_RecoveryDate_Consultant: logObject.PropertyValueDateTime = entity.RecoveryConsultantDate; break; case LogPropertyType.Contacts_StatusCare_Consultant: logObject.PropertyValueInt = entity.StatusCareConsultantId; break; case LogPropertyType.Contacts_StatusMap_Consultant: logObject.PropertyValueInt = entity.StatusMapConsultantId; break; } ActivityObjectChangeRepository.Create(logObject); } }
public static int LogRecoveryContact(ContactInfo entity) { try { var log = new ActivityLogInfo { FunctionId = entity.Id, FunctionType = (int)LogFunctionType.RecoveryConsultant, CreatedBy = UserRepository.GetCurrentUserInfo().UserID, }; log.Id = Create(log); LogObjectChange(entity, log, LogPropertyType.Contacts_Status, LogPropertyType.Contacts_RecoveryDate_Consultant, LogPropertyType.Contacts_AppointmentDate_Consultant); return log.Id; } catch { } return 0; }
public ActionResult CreateHotLine(ContactAddModel model) { int duplicateId; try { duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, model.ContactInfo.Mobile3, model.ContactInfo.Email, model.ContactInfo.Email2); if (duplicateId == 0) duplicateId = ContactRepository.ContactIsDuplicate(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, model.ContactInfo.Mobile3, model.ContactInfo.Email, model.ContactInfo.Email2); } catch { ViewBag.Message = "Hệ thống cache bị lỗi, vui lòng thử lại sau"; return CreateHotLine(); } var entity = new ContactInfo { CollectorId = 1, StatusMapConsultantId = 1, StatusCareConsultantId = 1, CreatedDate = DateTime.Now, LevelId = (int)LevelType.L1, RegisteredDate = DateTime.Now, Notes = model.ContactInfo.Notes, Email = model.ContactInfo.Email, Email2 = model.ContactInfo.Email2, TypeId = model.ContactInfo.TypeId, Gender = model.ContactInfo.Gender, Address = model.ContactInfo.Address, Fullname = model.ContactInfo.Fullname, HandoverConsultantDate = DateTime.Now, Birthday = model.Birthday.ToDateTime(), ChannelId = model.ContactInfo.ChannelId, BranchId = UserContext.GetDefaultBranch(), AppointmentConsultantDate = DateTime.Now, StatusId = (int)StatusType.HandoverConsultant, ProductSellId = model.ContactInfo.ProductSellId, CreatedBy = UserContext.GetCurrentUser().UserID, UserConsultantId = model.ContactInfo.UserConsultantId, Mobile1 = Util.CleanAlphabetAndFirstZero(model.ContactInfo.Mobile1), Mobile2 = Util.CleanAlphabetAndFirstZero(model.ContactInfo.Mobile2), }; //int a = ContactRepository.check_old_db(entity); //if (a > 0) //{ // ViewBag.Message = "Contact trùng với database cũ"; // return CreateHotLine(); //} var contactInfo = duplicateId == 0 ? null : ContactRepository.GetInfo(duplicateId); if (contactInfo == null) { try { // Save Contacts if (entity.UserConsultantId > 0) entity.StatusId = (int)StatusType.HandoverConsultant; entity.Id = ContactRepository.CreateHotline(entity); if (entity.Id > 0) { // Redis StoreData.LoadRedis(entity.Id); // Message ViewBag.Message = "Thêm mới contact thành công"; } else { ViewBag.Message = "Thêm mới contact bị lỗi, vui lòng thử lại sau"; //Redis StoreData.DeleteRedis(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, string.Empty, model.ContactInfo.Email, model.ContactInfo.Email2); } } catch { ViewBag.Message = "Thêm mới contact bị exception, vui lòng thử lại sau"; //Redis StoreData.DeleteRedis(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, string.Empty, model.ContactInfo.Email, model.ContactInfo.Email2); } } else { // Update email, phone UpdatePhone(contactInfo.Id, new List<string> { entity.Mobile1, entity.Mobile2, entity.Mobile3 }); // Email if (!entity.Email.IsStringNullOrEmpty()) { if (contactInfo.Email.IsStringNullOrEmpty()) contactInfo.Email = entity.Email; else if (contactInfo.Email != entity.Email && contactInfo.Email2.IsStringNullOrEmpty()) contactInfo.Email2 = entity.Email; } ContactRepository.Update(contactInfo); // Log duplicate entity.Id = contactInfo.Id; entity.TypeId = contactInfo.TypeId; ContactRepository.ContactUpdateDuplicate(entity.Id, entity.TypeId, entity.StatusId); // Message var user = StoreData.ListUser.FirstOrDefault(c => c.UserID == contactInfo.UserConsultantId) ?? UserRepository.GetInfo(contactInfo.UserConsultantId); ViewBag.Message = user == null ? "Sđt hoặc Email bạn nhập đã bị trùng với Ứng viên: " + contactInfo.Id + " - " + contactInfo.Fullname + " - Level " + contactInfo.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: " + contactInfo.Id + " - " + contactInfo.Fullname + " - Level " + contactInfo.LevelId + "- TVTS: " + user.FullName; } return CreateHotLine(); }
public ActionResult CreateTvts(ContactAddModel model) { int duplicateId; try { duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, model.ContactInfo.Mobile3, model.ContactInfo.Email, model.ContactInfo.Email2); if (duplicateId == 0) duplicateId = ContactRepository.ContactIsDuplicate(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, model.ContactInfo.Mobile3, model.ContactInfo.Email, model.ContactInfo.Email2); } catch { ViewBag.Message = "Hệ thống cache bị lỗi, vui lòng thử lại sau"; return CreateTvts(); } var entity = new ContactInfo { CreatedDate = DateTime.Now, LevelId = (int)LevelType.L1, RegisteredDate = DateTime.Now, Notes = model.ContactInfo.Notes, Email = model.ContactInfo.Email, Email2 = model.ContactInfo.Email2, TypeId = model.ContactInfo.TypeId, Gender = model.ContactInfo.Gender, Address = model.ContactInfo.Address, Fullname = model.ContactInfo.Fullname, Birthday = model.Birthday.ToDateTime(), BranchId = UserContext.GetDefaultBranch(), CollectorId = model.ContactInfo.CollectorId, ProductSellId = model.ContactInfo.ProductSellId, CreatedBy = UserContext.GetCurrentUser().UserID, Mobile1 = Util.CleanAlphabetAndFirstZero(model.ContactInfo.Mobile1), Mobile2 = Util.CleanAlphabetAndFirstZero(model.ContactInfo.Mobile2), StatusMapConsultantId = 1, StatusCareConsultantId = 1, HandoverConsultantDate = DateTime.Now, AppointmentConsultantDate = DateTime.Now, StatusId = (int)StatusType.HandoverConsultant, UserConsultantId = UserContext.GetCurrentUser().UserID, }; //int a = ContactRepository.check_old_db(entity); //if (a > 0) //{ // ViewBag.Message = "Contact trùng với database cũ"; // return CreateHotLine(); //} var contactInfo = duplicateId == 0 ? null : ContactRepository.GetInfo(duplicateId); if (contactInfo == null) { try { // Contacts entity.Id = ContactRepository.CreateTvts(entity); if (entity.Id > 0) { // Redis StoreData.LoadRedis(entity.Id); // Message ViewBag.Message = "Thêm mới contact thành công, bạn có thể chăm sóc luôn (" + "<a style=\"cursor: pointer;\" onclick=\"openDialog(" + entity.Id + ")\">Chăm sóc</a>)"; } else { ViewBag.Message = "Thêm mới contact bị lỗi, vui lòng thử lại sau"; //Redis StoreData.DeleteRedis(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, string.Empty, model.ContactInfo.Email, model.ContactInfo.Email2); } } catch { ViewBag.Message = "Thêm mới contact bị exception, vui lòng thử lại sau"; //Redis StoreData.DeleteRedis(model.ContactInfo.Mobile1, model.ContactInfo.Mobile2, string.Empty, model.ContactInfo.Email, model.ContactInfo.Email2); } } else { // Log duplicate entity.Id = contactInfo.Id; entity.TypeId = contactInfo.TypeId; ContactRepository.ContactUpdateDuplicate(entity.Id, entity.TypeId, entity.StatusId); if (contactInfo.UserConsultantId == 0) { // Update userId entity.BranchId = UserContext.GetDefaultBranch(); entity.CreatedBy = UserContext.GetCurrentUser().UserID; ContactRepository.ContactUpdateUserId(entity.Id, entity.UserConsultantId, entity.BranchId, entity.CreatedBy); // Message ViewBag.Message = "Contact đã có trong hệ thống, và chưa được ai chăm sóc, bạn có thể chăm sóc luôn (" + "<a style=\"cursor: pointer;\" onclick=\"openDialog(" + entity.Id + ")\">Chăm sóc</a>)"; } else if (contactInfo.UserConsultantId == entity.UserConsultantId) { // Update userId entity.BranchId = UserContext.GetDefaultBranch(); entity.CreatedBy = UserContext.GetCurrentUser().UserID; ContactRepository.ContactUpdateUserId(entity.Id, entity.UserConsultantId, entity.BranchId, entity.CreatedBy); ViewBag.Message = "Contact đã có trong hệ thống, bạn có thể chăm sóc luôn (" + "<a style=\"cursor: pointer;\" onclick=\"openDialog(" + entity.Id + ")\">Chăm sóc</a>)"; } else { if (contactInfo.StatusId != (int)StatusType.HandoverConsultant) { // Update userId entity.BranchId = UserContext.GetDefaultBranch(); entity.UserConsultantId = UserContext.GetCurrentUser().UserID; entity.CreatedBy = UserContext.GetCurrentUser().UserID; ContactRepository.ContactUpdateUserId(entity.Id, entity.UserConsultantId, entity.BranchId, entity.CreatedBy); ViewBag.Message = "Contact đã có trong hệ thống, bạn có thể chăm sóc luôn (" + "<a style=\"cursor: pointer;\" onclick=\"openDialog(" + entity.Id + ")\">Chăm sóc</a>)"; } else { var user = StoreData.ListUser.FirstOrDefault(c => c.UserID == contactInfo.UserConsultantId) ?? UserRepository.GetInfo(contactInfo.UserConsultantId); ViewBag.Message = user == null ? "Sđt hoặc Email bạn nhập đã bị trùng với Ứng viên: " + contactInfo.Id + " - " + contactInfo.Fullname + " - Level " + contactInfo.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: " + contactInfo.Id + " - " + contactInfo.Fullname + " - Level " + contactInfo.LevelId + "- TVTS: " + user.FullName; //haihm return CreateTvts(); } } } return CreateTvts(); }
public static void Update(ContactInfo info) { DataProvider.Instance().Contacts_Update(info.Id, info.Code, info.Fullname, info.Address, info.Birthday, info.Gender, info.Email, info.Email2, info.Notes, info.RegisteredDate, info.CreatedDate, info.ImportedDate, info.HandoverCollaboratorDate, info.RecoveryCollaboratorDate, info.AppointmentCollaboratorDate, info.CallCollaboratorDate, info.HandoverConsultantDate, info.RecoveryConsultantDate, info.AppointmentConsultantDate, info.CallConsultantDate, info.CollectorId, info.TypeId, info.ChannelId, info.CampaindTpeId, info.LandingPageId, info.TemplateAdsId, info.SearchKeywordId, info.PackageId, info.LevelId, info.BranchId, info.StatusId, info.ImportId, info.ContainerId, info.ProductSellId, info.ProductSoldId, info.StatusMapCollaboratorId, info.StatusCareCollaboratorId, info.StatusMapConsultantId, info.StatusCareConsultantId, info.UserImportId, info.UserErrorId, info.UserHandoverCollaboratorId, info.UserCollaboratorId, info.UserRecoveryCollaboratorId, info.UserHandoverConsultantId, info.UserConsultantId, info.UserRecoveryConsultantId, info.DraftCollaborator, info.DraftConsultant, info.CallInfoCollaborator, info.CallInfoConsultant, info.HandoverHistoryCollaboratorId, info.HandoverHistoryConsultantId, info.CallCount); }
public static int LogCreateContactTvtsDuplicate(ContactInfo entity) { try { var log = new ActivityLogInfo { FunctionId = entity.Id, CreatedBy = UserRepository.GetCurrentUserInfo().UserID, FunctionType = (int)LogFunctionType.CreateContactTvts, }; log.Id = Create(log); LogObjectChange(entity, log, LogPropertyType.Contacts_User_Consultant); return log.Id; } catch { } return 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"); // 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 string UpdateL1(FormDataCollection form) { var name = form.Get("name"); var notes = form.Get("notes"); var email1 = form.Get("email1"); var email2 = form.Get("email2"); var address = form.Get("address"); var id = form.Get("id").ToInt32(); var gender = form.Get("gender").ToInt32(); var birthday = form.Get("birthday").ToDateTime(); var productSellId = form.Get("productSellId").ToInt32(); var mobile1 = Util.CleanAlphabetAndFirstZero(form.Get("mobile1")); var mobile2 = Util.CleanAlphabetAndFirstZero(form.Get("mobile2")); var mobile3 = Util.CleanAlphabetAndFirstZero(form.Get("mobile3")); try { var duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(string.Empty, mobile2, string.Empty, string.Empty, string.Empty, id); if (duplicateId == 0) duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(string.Empty, string.Empty, mobile3, string.Empty, string.Empty, id); if (duplicateId == 0) duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(string.Empty, string.Empty, string.Empty, email1, string.Empty, id); if (duplicateId == 0) duplicateId = CheckDuplicateProvider.Instance().IsDuplicate(string.Empty, string.Empty, string.Empty, string.Empty, email2, id); if (duplicateId == 0) duplicateId = ContactRepository.ContactIsDuplicate(mobile1, mobile2, mobile3, email1, email2, id); if (duplicateId > 0 && duplicateId != id) { var contactInfoDb = ContactRepository.GetInfo(duplicateId); if (contactInfoDb == null) return "Cập nhật contact bị lỗi do trùng với contact khác trong hệ thống"; var user = StoreData.ListUser.FirstOrDefault(c => c.UserID == contactInfoDb.UserConsultantId) ?? UserRepository.GetInfo(contactInfoDb.UserConsultantId); return 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; } // Delete Redis StoreData.DeleteRedis(id); // Update var entity = new ContactInfo { Id = id, Notes = notes, Email = email1, Email2 = email2, Fullname = name, Gender = gender, Mobile1 = mobile1, Mobile2 = mobile2, Mobile3 = mobile3, Address = address, Birthday = birthday, ProductSellId = productSellId, }; ContactRepository.ContactUpdateL1(entity); // Load Redis StoreData.LoadRedis(entity.Id); return "Cập nhật contact thành công"; } catch { // Redis StoreData.DeleteRedis(mobile1, mobile2, mobile3, email1, email2, id); return "Cập nhật contact bị lỗi, vui lòng thử lại sau"; } }