public ManagersLocationViewModel(IManagersLocationView view) { _view = view; _employeeModel = new EmployeeModel(new EFUnitOfWork()); _callLogModel = new CallLogModel(); }
/// <summary> /// Default Class Constructor /// </summary> /// <param name="view">Interface View</param> public EmployeeMaintenanceViewModel(IEmployeeMaintenanceView view) { _view = view; _callCriteriaModel = new CallCriteriaModel(); _employeeModel = new EmployeeModel(); }
/// <summary> /// Service logic method /// </summary> /// <param name="arg"></param> private void DoWork(object arg) { for (; ; ) { if (iVantageImportStop.WaitOne(10000)) return; try { EmployeeModel employeeModel = new EmployeeModel(); employeeModel.ServiceWork(); } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while running the IVantage Import Service!\n{0}\n{1}", ex.Message, ex.StackTrace)); SettingsModel settings = new SettingsModel(); EmailModel emailModel = new EmailModel(); StringBuilder mailError = new StringBuilder(); mailError.AppendLine(string.Format("An error has ocurred while running the IVantage Import Service!\n{0}\n{1}", ex.Message, ex.StackTrace)); //MailUtility.SendMail(settings.GetITEmailOnError(), "", "", mailError.ToString(), "IVantage Import Service - Error occured on Employee Information", false, null); emailModel.SaveEmailList(settings.GetITEmailOnError(), "IVantage Import Service - Error occured on Employee Information", mailError.ToString(), "System", (int)Globals.Security.SystemEmployeeID); } } }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">isntance of the phone listing view</param> public PhoneListingViewModel(IPhoneListingView view) { _view = view; _employeeModel = new EmployeeModel(); _customerModel = new CustomerModel(); _divisionModel = new DivisionModel(); }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">Instance of the CustomerInfo View Interface</param> public CustomerInfoPresenter(ICustomerInfoView view) { this._view = view; this._customerModel = new CustomerModel(); this._divisionModel = new DivisionModel(); this._employeeModel = new EmployeeModel(); this._jobModel = new JobModel(); }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">Instance of the Process DPI View Interface</param> public RegionalMaintenanceViewModel(IRegionalMaintenanceView view) { _view = view; _regionModel = new RegionModel(); _employeeModel = new EmployeeModel(); _equipmentModel = new EquipmentModel(); _divisionModel = new DivisionModel(); }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">Instance of the CallEntry View Interface</param> public CallEntryViewModel(ICallEntryView view) { _view = view; _employeeModel = new EmployeeModel(); _equipmentModel = new EquipmentModel(); _callCriteriaModel = new CallCriteriaModel(); }
public void TestGetEmployee() { //Arrange EmployeeModel model = new EmployeeModel(new FakeUnitOfWork()); //Act CS_Employee result = model.GetEmployee(4); //Assert Assert.IsNotNull(result); }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">Instance of the Permit Info View Interface</param> public JobInfoPresenter(IJobInfoView view) { this._view = view; this._jobModel = new JobModel(); this._divisionModel = new DivisionModel(); this._customerModel = new CustomerModel(); this._employeeModel = new EmployeeModel(); _resourceAllocationModel = new ResourceAllocationModel(); }
public CustomerMaintenancePresenter(ICustomerMaintenanceView view) { _view = view; _customerMaintenanceViewModel = new CustomerMaintenanceViewModel(view); _customerModel = new CustomerModel(); _employeeModel = new EmployeeModel(); }
public void LoadLoggedEmployee() { using (_employeeModel = new EmployeeModel()) { CS_Employee employee = _employeeModel.GetEmployeeByLogin(_view.Username, _view.Domain); if (null != employee) _view.LoggedEmployee = employee.ID; } }
public void Dispose() { if (_callCriteriaModel != null) _callCriteriaModel.Dispose(); if (_employeeModel != null) _employeeModel.Dispose(); if (_equipmentModel != null) _equipmentModel.Dispose(); _equipmentModel = null; _employeeModel = null; _callCriteriaModel = null; }
public ResourceAllocationViewModel(IResourceAllocationView view) { _view = view; _equipmentModel = new EquipmentModel(); _divisionModel = new DivisionModel(); _employeeModel = new EmployeeModel(); _resourceAllocationModel = new ResourceAllocationModel(); _locationModel = new LocationModel(); _jobModel = new JobModel(); _callLogModel = new CallLogModel(); _divisionNumber = string.Empty; _name = string.Empty; _type = Globals.ResourceAllocation.Type.AddEmployee; }
public void GetOffCallNotificationList() { try { using (_employeeModel = new EmployeeModel()) { _view.OffCallNotificationList = _employeeModel.ListEmployeeOffCallHistoryNotification(DateTime.Now); } } catch (Exception ex) { if (null != ex.InnerException) Logger.Write(string.Format("An error has occurred while trying to get the Off Call Notification LIst\n{0}\n{1}\n{2}\n{3}", ex.Message, ex.StackTrace, ex.InnerException.Message, ex.InnerException.StackTrace)); else Logger.Write(string.Format("An error has occurred while trying to get the Off Call Notification LIst\n{0}\n{1}", ex.Message, ex.StackTrace)); } }
/// <summary> /// Filter the persons to Advise grid based on filter type and value /// </summary> public void FilterContactOrEmployee() { try { List<object> GenericList = new List<object>(); using (_customerModel = new CustomerModel()) { using (_employeeModel = new EmployeeModel()) { switch (_view.TypeOfPerson) { case Globals.CallEntry.typeOfPerson.Contact: if (_view.CustomerId.HasValue) GenericList.AddRange(_customerModel.ListAllFilteredContacts(_view.FilteredEmployeeCustomerName, _view.CustomerId.Value)); break; case Globals.CallEntry.typeOfPerson.Employee: GenericList.AddRange(_employeeModel.ListAllFilteredEmployee(_view.FilteredEmployeeCustomerName)); break; case Globals.CallEntry.typeOfPerson.Both: if (_view.CustomerId.HasValue) GenericList.AddRange(_customerModel.ListAllFilteredContacts(_view.FilteredEmployeeCustomerName, _view.CustomerId.Value)); GenericList.AddRange(_employeeModel.ListAllFilteredEmployee(_view.FilteredEmployeeCustomerName)); break; } _view.PersonGridDataSource = GenericList; } } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to load the contact list.\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An Internal Error has ocurred while trying to load the contact list.", false); } }
/// <summary> /// List all added resources /// </summary> public void ListAllAddedEmployess() { try { using (_employeeModel = new EmployeeModel()) { IList<CS_Employee> employees = _employeeModel.ListAllAddedEmployee_CallLogInfo(_view.CallID.Value, (int)Globals.CallEntry.CallLogResourceType.Employee); for (int i = 0; i < employees.Count; i++) { CS_Employee employee = employees[i]; _view.SelectedPersons.Add(new CS_CallLogResource() { EmployeeID = employee.ID, CS_Employee = employee }); } } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to List all Employees.\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); } }
/// <summary> /// Load data for call criteria /// </summary> public void ListAllEmployeeCallLogInfoCallCriteria() { try { if (_view.JobId.HasValue && _view.CallID.HasValue) { IList<CS_CallLogResource> resources = new List<CS_CallLogResource>(); using (_callLogModel = new CallLogModel()) { resources = _callLogModel.ListCallLogResourceByCallEntry(_view.CallID.Value); } List<CallCriteriaResourceVO> source = new List<CallCriteriaResourceVO>(); for (int i = 0; i < resources.Count; i++) { if (resources[i].Type == (int)Globals.CallCriteria.EmailVOType.Employee) { using (_employeeModel = new EmployeeModel()) { source.Add(_employeeModel.GetEmployeeDataForInitialAdvise(resources[i].EmployeeID.Value, _view.CallID.Value)); } } else { using (_customerModel = new CustomerModel()) { source.Add(_customerModel.GetContactDataForInitialAdvise(resources[i].ContactID.Value, _view.CallID.Value)); } } } _view.PersonInitialAdviseGridDataSource = source; } else { IList<EmailVO> resourceList = new List<EmailVO>(); List<CallCriteriaResourceVO> source = new List<CallCriteriaResourceVO>(); List<int> callCriteriasIDs = new List<int>(); using (_callCriteriaModel = new CallCriteriaModel()) { resourceList = _callCriteriaModel.ListReceiptsByCallLog(_view.SelectedCallType.ID.ToString(), _view.JobId.Value, null, out callCriteriasIDs); _view.CallCriteriaIDs = callCriteriasIDs; } for (int i = 0; i < resourceList.Count; i++) { if (resourceList[i].Type == (int)Globals.CallCriteria.EmailVOType.Employee) { using (_employeeModel = new EmployeeModel()) { source.Add(_employeeModel.GetEmployeeDataForInitialAdvise(resourceList[i].PersonID)); } } else { using (_customerModel = new CustomerModel()) { source.Add(_customerModel.GetContactDataForInitialAdvise(resourceList[i].PersonID)); } } } _view.PersonInitialAdviseGridDataSource = source; } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to List .\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); } }
public void Dispose() { _customerModel.Dispose(); _employeeModel.Dispose(); _employeeModel = null; _customerModel = null; }
public void BindEmployee() { int? jobId = null; if (_view.FilterEmployeeByJobID) jobId = _view.JobID; using (_employeeModel = new EmployeeModel()) { _view.EmployeeDataSource = _employeeModel.ListFilteredEmployee(_view.EmployeeFilter.Value, _view.EmployeeFilterValue, jobId); } }
public void BindEmployeeByID() { using (_employeeModel = new EmployeeModel()) { List<CS_Employee> returnList = new List<CS_Employee>(); if (_view.EditEmployeeID.HasValue) returnList.Add(_employeeModel.GetEmployee(_view.EditEmployeeID.Value)); _view.EmployeeDataSource = returnList; } }
public ManagersLocationViewModel(IManagersLocationView view, EmployeeModel employeeModel) { _view = view; _employeeModel = employeeModel; }
/// <summary> /// Add employee to a selected resources list /// </summary> public void AddEmployeeToCallEntry() { try { using (_employeeModel = new EmployeeModel()) { CS_Employee employee = _employeeModel.GetEmployee(_view.SelectedEmployeeId); _view.SelectedPersons.Add(new CS_CallLogResource() { EmployeeID = employee.ID, CS_Employee = employee }); } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to AddEmployeeToCallEntry.\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); } }
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> /// Class constructor /// </summary> /// <param name="view">Instance of the Managerns Location View</param> public ManagersLocationPresenter(IManagersLocationView view) { _view = view; _viewModel = new ManagersLocationViewModel(_view); _model = new EmployeeModel(); }
public void ListEmployeeByName() { try { long divisionId = 0; if (!string.IsNullOrEmpty(_view.ContextKey)) divisionId = Convert.ToInt32(_view.ContextKey); _employeeModel = new EmployeeModel(); _view.EmployeeList = _employeeModel.ListFilteredEmployeeByName(divisionId, _view.PrefixText).OrderBy(e => e.CS_Division, new Globals.JobRecord.EmployeeComparer()).ThenBy(e => e.FullName).ToList(); } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to load the Contact Information!\n{0}\n{1}", ex.Message, ex.StackTrace)); } }
/// <summary> /// List of all project manager /// </summary> public void ListProjectManager() { try { using (_employeeModel = new EmployeeModel()) { _view.ProjectManagerList = _employeeModel.ListAllEmployeeProjectManagerByName(_view.PrefixText); } } catch (Exception ex) { Logger.Write(string.Format("There was an error loading the Project Managers\n{0}\n{1}", ex.Message, ex.StackTrace)); } }
public void TestIfEmployeeIsBeingUpdated() { // Arrange FakeObjectSet<CS_Employee> fakeEmployeeList = new FakeObjectSet<CS_Employee>(); FakeObjectSet<CS_CallCriteria> fakeCallCriteriaList = new FakeObjectSet<CS_CallCriteria>(); FakeObjectSet<CS_CallCriteriaValue> fakeCallCriteriaValueList = new FakeObjectSet<CS_CallCriteriaValue>(); FakeObjectSet<CS_EmployeeCoverage> fakeEmployeeCoverageList = new FakeObjectSet<CS_EmployeeCoverage>(); FakeObjectSet<CS_EmployeeOffCallHistory> fakeEmployeeOffCallList = new FakeObjectSet<CS_EmployeeOffCallHistory>(); FakeObjectSet<CS_Settings> fakeSettingsList = new FakeObjectSet<CS_Settings>(); FakeObjectSet<CS_CallLog> fakeCallLogList = new FakeObjectSet<CS_CallLog>(); FakeObjectSet<CS_CallLogResource> fakeCallLogResourceList = new FakeObjectSet<CS_CallLogResource>(); FakeObjectSet<CS_Resource> fakeResourceList = new FakeObjectSet<CS_Resource>(); FakeObjectSet<CS_PhoneNumber> fakePhoneList = new FakeObjectSet<CS_PhoneNumber>(); fakeEmployeeList.AddObject( new CS_Employee() { ID = 1, Active = true, HasAddressChanges = false, HasPhoneChanges = false, } ); fakeEmployeeList.AddObject( new CS_Employee() { ID = 2, Active = true, HasAddressChanges = false, HasPhoneChanges = false, } ); fakeSettingsList.AddObject( new CS_Settings() { ID = (int)Globals.Configuration.Settings.AddressChangeNotification, Description = "*****@*****.**" } ); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Employee>()).Returns(fakeEmployeeList); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_CallCriteria>()).Returns(fakeCallCriteriaList); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_CallCriteriaValue>()).Returns(fakeCallCriteriaValueList); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_EmployeeCoverage>()).Returns(fakeEmployeeCoverageList); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_EmployeeOffCallHistory>()).Returns(fakeEmployeeOffCallList); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Settings>()).Returns(fakeSettingsList); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_CallLog>()).Returns(fakeCallLogList); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_CallLogResource>()).Returns(fakeCallLogResourceList); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Resource>()).Returns(fakeResourceList); mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_PhoneNumber>()).Returns(fakePhoneList); CS_Employee updateEmployee = new CS_Employee() { ID = 1, Address = "Testing Address" }; CS_CallCriteria callCriteria = new CS_CallCriteria() { EmployeeID = 1, Active = true }; IList<CS_CallCriteriaValue> callCriteriaValueList = new List<CS_CallCriteriaValue>(); callCriteriaValueList.Add(new CS_CallCriteriaValue() { CallCriteriaTypeID = 1, Value = "testing", Active = true }); CS_EmployeeCoverage coverage = new CS_EmployeeCoverage() { EmployeeID = 1, Active = true, CoverageStartDate = new DateTime(2011, 8, 29), Duration = 10, DivisionID = 1, CS_Employee = new CS_Employee() { ID = 1, Active = true, FullName = "Santos, Kleiton" }, CS_Division = new CS_Division() { ID = 1, Active = true, Name = "001" } }; CS_EmployeeOffCallHistory offCall = new CS_EmployeeOffCallHistory() { EmployeeID = 1, ProxyEmployeeID = 2, Active = true, OffCallStartDate = new DateTime(2011, 8, 29), OffCallEndDate = new DateTime(2011, 8, 31), OffCallReturnTime = new TimeSpan(10, 0, 0), CS_Employee = new CS_Employee() { ID = 1, Active = true, FullName = "Santos, Kleiton" }, CS_Employee_Proxy = new CS_Employee() { ID = 2, Active = true, FullName = "Burton, Cynthia" } }; // Act EmployeeModel model = new EmployeeModel(mockUnitOfWork.Object); model.SaveEmployee(updateEmployee, offCall, coverage, "system", true, true, new List<DataContext.VO.PhoneNumberVO>()); // Assert Assert.AreEqual(1, fakeCallCriteriaList.Count()); Assert.AreEqual(1, fakeCallCriteriaValueList.Count()); Assert.AreEqual(1, fakeEmployeeOffCallList.Count()); Assert.AreEqual(1, fakeEmployeeCoverageList.Count()); }
public void GetEmployeeName() { string name = "--"; if (_view.Identifier.HasValue) { using (_employeeModel = new EmployeeModel()) { name = _employeeModel.GetEmployee(_view.Identifier.Value).FullName; } } _view.ParamName = name; }