public void TestGetCallType() { //Arrange CallLogModel model = new CallLogModel(new FakeUnitOfWork()); //Act CS_CallType result = model.GetCallType(1); //Assert Assert.IsNotNull(result); }
/// <summary> /// Saves a call log /// </summary> public void SaveCallLog() { try { CS_CallLog callEntry = _view.CallEntryEntity; if (_view.DynamicFieldsControls.Count > 0) { callEntry.Xml = DynamicFieldsParser.CreateXmlFromControls(_view.DynamicFieldsControls, _view.DynamicControlXmlString); if (string.IsNullOrEmpty(callEntry.Note) && !string.IsNullOrEmpty(callEntry.Xml)) { callEntry.Note = "Job #:<Text>"; if (_view.JobId != (int)Globals.GeneralLog.ID) callEntry.Note += _view.PrefixedJobNumber + "<BL>"; else callEntry.Note += "PA99999 - General Log<BL>"; callEntry.Note += DynamicFieldsParser.FormatDynamicFieldsData(DynamicFieldsParser.GetDynamicFieldControlsProperties(callEntry.Xml)); callEntry.Note += _viewModel.FormatResourcesOrPersonsData(); } } if (_view.CopyToShiftTransferLog) callEntry.ShiftTransferLog = true; if (_view.CopyToGeneralLog) callEntry.HasGeneralLog = true; IList<CS_CallLog_LocalEquipmentType> callLogEqTypeList = new List<CS_CallLog_LocalEquipmentType>(); for (int i = 0; i < _view.SelectedEquipmentTypes.Count; i++) { if (!_view.CallID.HasValue) callLogEqTypeList.Add(_viewModel.ParseVOToCallLogEquipmentTypeEntity(callEntry.ID, _view.SelectedEquipmentTypes[i], false)); else callLogEqTypeList.Add(_viewModel.ParseVOToCallLogEquipmentTypeEntity(callEntry.ID, _view.SelectedEquipmentTypes[i], true)); } using (_callLogModel = new CallLogModel()) { _callLogModel.SaveCallLogData(callEntry, _view.SelectedPersons.ToList(), _view.SelectedResources.ToList(), callLogEqTypeList, callEntry.ID != 0, _view.CopyToGeneralLog); IList<int> callLogHistory = _view.CallLogHistoryList; callLogHistory.Add(callEntry.ID); _view.CallLogHistoryList = callLogHistory; //IList<CS_CallLog_LocalEquipmentType> callLogEqTypeList = new List<CS_CallLog_LocalEquipmentType>(); //for (int i = 0; i < _view.SelectedEquipmentTypes.Count; i++) //{ // callLogEqTypeList.Add(_viewModel.ParseVOToCallLogEquipmentTypeEntity(callEntry.ID, _view.SelectedEquipmentTypes[i])); //} //if (callLogEqTypeList.Count > 0) // _callLogModel.SaveCallLogEquipmentTypeList(callLogEqTypeList); if (!_view.SaveAndContinue) { CS_CallType calltype = _callLogModel.GetCallType(callEntry.CallTypeID); _view.OpenEmailPage = calltype.SendEmail; } } _view.SavedSuccessfuly = true; } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to save the call log.\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An Internal Error has ocurred while trying to save the Information. Please try again.", false); _view.SavedSuccessfuly = false; } }
private void BindList() { CustomerModel customerModel; EmployeeModel employeeModel; LocationModel locationModel; DivisionModel divisionModel; JobModel jobModel; CallLogModel callLogModel; EquipmentModel equipmentModel; IList<CS_Customer> customerDataSource; IList<CS_Contact> contactDataSource; IList<CS_Employee> employeeDataSource; IList<CS_JobStatus> jobStatusDataSource; IList<CS_City> cityDataSource; IList<CS_Division> divisionDataSource; IList<CS_PriceType> priceTypeDataSource; IList<CS_JobAction> jobActionDataSource; IList<CS_Job> jobNumberDataSource; IList<CS_ZipCode> zipCodeDataSource; IList<CS_State> stateDataSource; IList<CS_CallType> callTypeDataSource; IList<CS_EquipmentType> equipmentTypeDataSource; IList<CS_Equipment> equipmentDataSource; IList<CS_LocalEquipmentType> localEquipmentTypeDataSource; switch (Request.QueryString["AutoCompleteSource"]) { case "Customer": customerModel = new CustomerModel(); customerDataSource = customerModel.ListAllCustomers().OrderBy(e => e.Name).ToList(); ViewStateList = customerDataSource; break; case "Contact": customerModel = new CustomerModel(); contactDataSource = customerModel.ListAllFilteredContactsByName(long.Parse(Request.QueryString["FilterId"]), "").OrderBy(e => e.LastName).ThenBy(e => e.Name).ToList(); ViewStateList = contactDataSource; break; case "DynamicsContact": customerModel = new CustomerModel(); contactDataSource = customerModel.ListFilteredContactsByName(long.Parse(Request.QueryString["FilterId"]), true, "").OrderBy(e => e.Attn).ToList(); ViewStateList = contactDataSource; break; case "CustomerServiceContact": customerModel = new CustomerModel(); contactDataSource = customerModel.ListFilteredContactsByName(long.Parse(Request.QueryString["FilterId"]), false, "").OrderBy(e => e.LastName).ThenBy(e => e.Name).ToList(); ViewStateList = contactDataSource; break; case "Employee": employeeModel = new EmployeeModel(); if (Request.QueryString["FilterId"] != "0") employeeDataSource = employeeModel.ListAllFilteredEmployee(long.Parse(Request.QueryString["FilterId"])).OrderBy(e => e.CS_Division.Name).ThenBy(e => e.FullName).ToList(); else employeeDataSource = employeeModel.ListAllEmployee().OrderBy(e => e.CS_Division.Name).ThenBy(e => e.FullName).ToList(); ViewStateList = employeeDataSource; break; case "EmployeeWithDivision": employeeModel = new EmployeeModel(); if (Request.QueryString["FilterId"] != "0") employeeDataSource = employeeModel.ListAllFilteredEmployee(long.Parse(Request.QueryString["FilterId"])).OrderBy(e => e.CS_Division.Name).ThenBy(e => e.FullName).ToList(); else employeeDataSource = employeeModel.ListAllEmployee().OrderBy(e => e.CS_Division, new Globals.JobRecord.EmployeeComparer()).ThenBy(e => e.FullName).ToList(); ViewStateList = employeeDataSource; break; case "JobStatus": jobModel = new JobModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0") { jobStatusDataSource = new List<CS_JobStatus>(); jobStatusDataSource.Add(jobModel.GetJobStatus(int.Parse(Request.QueryString["FilterId"]))); } else jobStatusDataSource = jobModel.ListAllJobStatus(); ViewStateList = jobStatusDataSource; break; case "JobStatusJobRecord": jobModel = new JobModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0" && Request.QueryString["FilterId"] != Globals.JobRecord.JobStatus.ClosedHold.ToString()) { jobStatusDataSource = new List<CS_JobStatus>(); jobStatusDataSource.Add(jobModel.GetJobStatus(int.Parse(Request.QueryString["FilterId"]))); } else { jobStatusDataSource = jobModel.ListAllJobStatus(); if (jobStatusDataSource.Count > 0) { CS_JobStatus jobStatus = jobStatusDataSource.Where(w => w.ID == (int)Globals.JobRecord.JobStatus.ClosedHold).FirstOrDefault(); if (null != jobStatus) jobStatusDataSource.Remove(jobStatus); } } ViewStateList = jobStatusDataSource; break; case "State": locationModel = new LocationModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString.Get("FilterId") != "0") stateDataSource = locationModel.GetStateByCountryId(int.Parse(Request.QueryString.Get("FilterId"))); else stateDataSource = locationModel.ListAllStates(); ViewStateList = stateDataSource; break; case "StateByDivision": locationModel = new LocationModel(); stateDataSource = locationModel.ListAllStatesByAllocatedDivision(); ViewStateList = stateDataSource; break; case "City": locationModel = new LocationModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString.Get("FilterId") != "0") cityDataSource = locationModel.GetCityByState(int.Parse(Request.QueryString.Get("FilterId"))).OrderBy(e => e.Name).ToList(); else cityDataSource = locationModel.ListAllCities().OrderBy(e => e.Name).ToList(); ViewStateList = cityDataSource; break; case "Division": divisionModel = new DivisionModel(); divisionDataSource = divisionModel.ListAllDivision(); ViewStateList = divisionDataSource; break; case "PriceType": jobModel = new JobModel(); priceTypeDataSource = jobModel.ListAllPriceTypes(); ViewStateList = priceTypeDataSource; break; case "JobAction": jobModel = new JobModel(); jobActionDataSource = jobModel.ListAllJobActions().OrderBy(w => w.Description).ToList(); ViewStateList = jobActionDataSource; break; case "ZipCode": locationModel = new LocationModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString.Get("FilterId") != "0") zipCodeDataSource = locationModel.GetZipCodeByCityId(int.Parse(Request.QueryString.Get("FilterId"))).OrderBy(e => e.ZipCodeNameEdited).ToList(); else zipCodeDataSource = locationModel.ListAllZipCodes(); ViewStateList = zipCodeDataSource; break; case "JobNumber": jobModel = new JobModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0") { jobNumberDataSource = new List<CS_Job>(); jobNumberDataSource.Add(jobModel.GetJobById(int.Parse(Request.QueryString["FilterId"]))); } else jobNumberDataSource = jobModel.ListAllJobs(); ViewStateList = jobNumberDataSource; break; case "JobNumberByStatus": jobModel = new JobModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0") { jobNumberDataSource = new List<CS_Job>(); jobNumberDataSource = jobModel.ListAllJobsByNumber("", Request.QueryString["FilterId"]); } else jobNumberDataSource = jobModel.ListAllJobs(); ViewStateList = jobNumberDataSource; break; case "JobNumberWithGeneral": jobModel = new JobModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0") { jobNumberDataSource = new List<CS_Job>(); jobNumberDataSource.Add(jobModel.GetJobById(int.Parse(Request.QueryString["FilterId"]))); } else { List<CS_Job> source = new List<CS_Job>(); source.Add(jobModel.GetGeneralJob()); source.AddRange(jobModel.ListAllJobs()); jobNumberDataSource = source; } ViewStateList = jobNumberDataSource; break; case "BillableJobNumber": jobModel = new JobModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0") { jobNumberDataSource = new List<CS_Job>(); jobNumberDataSource.Add(jobModel.GetJobById(int.Parse(Request.QueryString["FilterId"]))); } else jobNumberDataSource = jobModel.ListAllBillableJobs(); ViewStateList = jobNumberDataSource; break; case "CallType": callLogModel = new CallLogModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0") { callTypeDataSource = new List<CS_CallType>(); callTypeDataSource.Add(callLogModel.GetCallType(int.Parse(Request.QueryString["FilterId"]))); } else callTypeDataSource = callLogModel.ListAllCallType(); ViewStateList = callTypeDataSource; break; case "EquipmentType": equipmentModel = new EquipmentModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0") { equipmentTypeDataSource = new List<CS_EquipmentType>(); equipmentTypeDataSource.Add(equipmentModel.GetEquipmentType(int.Parse(Request.QueryString["FilterId"]))); } else equipmentTypeDataSource = equipmentModel.ListAllEquipmentType(); ViewStateList = equipmentTypeDataSource; break; case "Equipment": equipmentModel = new EquipmentModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0") { equipmentDataSource = new List<CS_Equipment>(); equipmentDataSource = equipmentModel.GetEquipmentByEqType(int.Parse(Request.QueryString["FilterId"])).OrderBy(w => w.Name).ToList(); } else equipmentDataSource = equipmentModel.ListAllEquipment().OrderBy(w => w.Name).ToList(); ; ViewStateList = equipmentDataSource; break; case "LocalEquipmentType": equipmentModel = new EquipmentModel(); if (!string.IsNullOrEmpty(Request.QueryString.Get("FilterId")) && Request.QueryString["FilterId"] != "0") { localEquipmentTypeDataSource = new List<CS_LocalEquipmentType>(); localEquipmentTypeDataSource.Add(equipmentModel.GetLocalEquipmentTypeByID(int.Parse(Request.QueryString["FilterId"]))); } else localEquipmentTypeDataSource = equipmentModel.ListAllLocalEquipmentType(); ViewStateList = localEquipmentTypeDataSource; break; case "ProjectManager": employeeModel = new EmployeeModel(); employeeDataSource = employeeModel.ListAllEmployeeProjectManager(); ViewStateList = employeeDataSource; break; default: break; } }
/// <summary> /// Sets Selected CallType /// </summary> public void GetCallType() { try { using (_callLogModel = new CallLogModel()) { _view.SelectedCallType = _callLogModel.GetCallType(_view.CallTypeId); } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to GetCallType.\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An Internal Error has ocurred while trying to load the Information. Please try again.", false); } }