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