public void TestUpdateEquipment() { //Arrange CS_Equipment equipment = new CS_Equipment() { Active = true, ID = 1, Name = "Xyz", Status = "Up", HeavyEquipment = false }; FakeObjectSet<CS_Equipment> fakeEquipment = new FakeObjectSet<CS_Equipment>(); fakeEquipment.AddObject(equipment); Mock<IUnitOfWork> mockUnitWork = new Mock<IUnitOfWork>(); mockUnitWork.Setup(w => w.CreateObjectSet<CS_Equipment>()).Returns(fakeEquipment); EquipmentModel model = new EquipmentModel(mockUnitWork.Object); //Act model.UpdateMaintenanceEquipment(equipment); CS_Equipment csEquipment = model.GetEquipment(1); //Assert Assert.AreEqual(Globals.EquipmentMaintenance.Status.Up.ToString(), csEquipment.Status, "Error on Status Field"); Assert.AreEqual(false, csEquipment.HeavyEquipment, "Error on heavyequipment field."); }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">Instance of View Interface</param> public EquipmentMaintenancePresenter(IEquipmentMaintenanceView view) { _view = view; _viewModel = new EquipmentMaintenanceViewModel(_view); _equipmentModel = new EquipmentModel(); _jobModel = new JobModel(); }
public MapPlottingPresenter(IMapPlottingView view) { _view = view; _divisionModel = new DivisionModel(); _jobModel = new JobModel(); _equipmentModel = new EquipmentModel(); _regionModel = new RegionModel(); }
/// <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(); }
/// <summary> /// List equipment by equipment type /// </summary> public void ListAllEquipmentByEqType() { try { using (_equipmentModel = new EquipmentModel()) { _view.EquipmentType = _equipmentModel.ListAllEquipmentByEqType(int.Parse(_view.ContextKey), _view.PrefixText); } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to load the Equipment Information!\n{0}\n{1}", ex.Message, ex.StackTrace)); } }
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; }
/// <summary> /// Shows an Equipment list of all active Equipments /// </summary> public void ListAllEquipmentAdd() { try { using (_equipmentModel = new EquipmentModel()) { _view.EquipmentInfoListData = _equipmentModel.ListAllHeavyCombo() as List<CS_View_EquipmentInfo>; _viewModel.GetFirstTierEquipmentList(); } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to load the Equipment Information!\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An Error has ocurred while trying to load the Equipment Information. Please try again.", false); } }
/// <summary> /// Service logic method /// </summary> /// <param name="arg"></param> private void DoWork(object arg) { for (; ; ) { if (dossierImportStop.WaitOne(20000)) return; try { EquipmentModel equipmentModel = new EquipmentModel(); equipmentModel.ServiceWork(); } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while running the Dossier Import Service!\n{0}\n{1}", ex.Message, ex.StackTrace)); } } }
/// <summary> /// Service logic method /// </summary> /// <param name="arg"></param> public void EquipmentPermitDoWork(object arg) { int miliSecondsTimeOut = Convert.ToInt32(ConfigurationManager.AppSettings["MilisecondsTimeOut"]); for (; ; ) { if (EquipmentPermitDoWorkServiceStop.WaitOne(miliSecondsTimeOut)) return; try { EquipmentModel equipmentModel = new EquipmentModel(); equipmentModel.CreateLapsedPermitsEmail(); } catch (Exception ex) { Logger.Write(string.Format("An error has ocurred while running the Preset Watch Service!\n{0}\n{1}", ex.Message, ex.StackTrace)); } } }
public void GetLocalEquipmentTypelList() { try { using (_equipmentModel = new EquipmentModel()) { _view.LocalEquipmentTypeList = _equipmentModel.ListAllLocalEquipmentTypeByName(_view.PrefixText); } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to load the local equipment type Information!\n{0}\n{1}", ex.Message, ex.StackTrace)); } }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">Instance of View Interface</param> public EquipmentMaintenanceViewModel(IEquipmentMaintenanceView view) { _view = view; _equipmentModel = new EquipmentModel(); _callLogModel = new CallLogModel(); }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">Instance of the EquipmentRequested View Interface</param> /// <param name="equipmentModel">Instance of the Equipment Model class</param> public EquipmentRequestedPresenter(IEquipmentRequestedView view, EquipmentModel equipmentModel) { this._view = view; this._equipmentModel = equipmentModel; }
public PermittingViewModel(IPermittingView view) { _view = view; _equipmentModel = new EquipmentModel(new EFUnitOfWork()); }
public void BindEquipment() { int? joId = null; if (_view.FilterVehiclesByJobID) joId = _view.JobID; using (_equipmentModel = new EquipmentModel()) { if (_view.EquipmentFilter.HasValue && !string.IsNullOrEmpty(_view.EquipmentFilterValue)) _view.FilteredEquipmentsDataSource = _equipmentModel.ListFilteredEquipmentInfo(_view.EquipmentFilter.Value, _view.EquipmentFilterValue, joId); else if (joId.HasValue) _view.FilteredEquipmentsDataSource = _equipmentModel.ListAllComboByJob(joId.Value); else _view.FilteredEquipmentsDataSource = new List<CS_View_EquipmentInfo>(); } }
public PermittingViewModel(IPermittingView view, EquipmentModel equipmentModel) { _view = view; _equipmentModel = equipmentModel; }
/// <summary> /// List all equipment type /// </summary> public void ListAllEquipmentType() { try { using (_equipmentModel = new EquipmentModel()) { _view.EquipmentTypeList = _equipmentModel.ListAllEquipmentType(); } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to load the Call Type Information!\n{0}\n{1}", ex.Message, ex.StackTrace)); } }
public void GetVehicleByEquipmentID() { using (_equipmentModel = new EquipmentModel()) { IList<CS_View_EquipmentInfo> list = new List<CS_View_EquipmentInfo>(); CS_View_EquipmentInfo equipment = _equipmentModel.GetSpecificEquipmentFromView(_view.CurrentFirstAlertVehicleEquipmentID); if (equipment != null) { list.Add(equipment); _view.FilteredEquipmentsDataSource = list; } } }
/// <summary> /// This constructor is used only when testing with Mocks /// </summary> /// <param name="view"></param> /// <param name="model"></param> public PermittingPresenter(IPermittingView view, EquipmentModel model) { _view = view; _equipmentModel = model; }
public PermittingPresenter(IPermittingView view) { _view = view; _viewModel = new PermittingViewModel(view); _equipmentModel = new EquipmentModel(); }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">Instance of the EquipmentRequested View Interface</param> public EquipmentRequestedPresenter(IEquipmentRequestedView view) { this._view = view; this._equipmentModel = new EquipmentModel(); }
/// <summary> /// Shows an Equipment List based on search parameteres /// </summary> public void ListFilteredEquipmentAdd() { try { using (_equipmentModel = new EquipmentModel()) { List<CS_View_EquipmentInfo> lstEquipmentInfo = _equipmentModel.ListFilteredHeavyEquipmentInfo(_view.EquipmentFilter, _view.EquipmentFilterValue, "DivisionName") as List<CS_View_EquipmentInfo>; switch (_view.SortColumn) { case Globals.Common.Sort.EquipmentSortColumns.None: _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.DivisionName).ThenBy(e => e.ComboName).ThenBy(e => e.UnitNumber).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.DivisionName: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.DivisionName).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.DivisionName).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.DivisionState: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.DivisionState).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.DivisionState).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.ComboName: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.ComboName).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.ComboName).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.UnitNumber: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.UnitNumber).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.UnitNumber).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.Descriptor: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.Descriptor).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.Descriptor).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.Status: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.Status).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.Status).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.JobLocation: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.JobLocation).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.JobLocation).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.Type: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.Type).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.Type).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.OperationStatus: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.EquipmentStatus).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.EquipmentStatus).ToList(); break; case Globals.Common.Sort.EquipmentSortColumns.JobNumber: if (_view.SortDirection == Globals.Common.Sort.SortDirection.Ascending) _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.JobNumber).ToList(); else _view.EquipmentInfoListData = lstEquipmentInfo.OrderByDescending(e => e.JobNumber).ToList(); break; default: _view.EquipmentInfoListData = lstEquipmentInfo.OrderBy(e => e.DivisionName).ThenBy(e => e.ComboName).ThenBy(e => e.UnitNumber).ToList(); break; } _viewModel.GetFirstTierEquipmentList(); } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to load the Employee Information!\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An Internal Error has ocurred while trying to filter the Information. Please try again.", false); } }
public void GetEquipmentTypeByEquipment() { try { using (_equipmentModel = new EquipmentModel()) { CS_EquipmentType eqType = _equipmentModel.GetEquipmentTypeByEquipmentId(_view.EquipmentId); _view.ReturnDataObject = new Globals.SampleDataObject() { Id = eqType.ID, Name = eqType.Name }; } } catch (Exception ex) { if (null != ex.InnerException) Logger.Write(string.Format("An error has occurred while trying to get the Equipment Type information\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 Equipment Type information\n{0}\n{1}", ex.Message, ex.StackTrace)); } }
public void GetEquipmentPermitNotificationList() { try { using (_equipmentModel = new EquipmentModel()) { _view.EquipmentPermitNotificationList = _equipmentModel.ListEquipmentPermitNotification(DateTime.Now); } } catch (Exception ex) { if (null != ex.InnerException) Logger.Write(string.Format("An error has occurred while trying to get the EquipmentPermit 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 EquipmentPermit Notification LIst\n{0}\n{1}", ex.Message, ex.StackTrace)); } }
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; } }
public DefaultPageViewModel(IDefaultPageView view) { _view = view; _equipmentModel = new EquipmentModel(); }
private IList<CS_Resource> UpdateAddedResources(int jobId, IList<CS_Resource> resourceList, string username, DateTime callDate) { IList<CS_Resource> updatedResource = new List<CS_Resource>(); IList<CS_Resource> addedResource = new List<CS_Resource>(); IList<CS_Resource> resourceSaved = null; if (resourceList != null && resourceList.Count > 0) { resourceSaved = new List<CS_Resource>(); foreach (CS_Resource resource in resourceList) { if (resource.ID > 0) { resource.ModificationDate = DateTime.Now; resource.ModifiedBy = username; updatedResource.Add(resource); } else { resource.JobID = jobId; resource.CreationDate = DateTime.Now; resource.CreatedBy = username; resource.ModificationDate = DateTime.Now; resource.ModifiedBy = username; addedResource.Add(resource); } } _resourceRepository.AddList(addedResource); _resourceRepository.UpdateList(updatedResource); if (null != updatedResource && updatedResource.Count > 0) { UpdateStartDatetime(updatedResource); DPIModel dpiModel = new DPIModel(); IList<int> equipmentList = updatedResource.Where(e => e.EquipmentID.HasValue).Select(e => e.EquipmentID.Value).ToList(); IList<int> employeeList = updatedResource.Where(e => e.EmployeeID.HasValue).Select(e => e.EmployeeID.Value).ToList(); dpiModel.UpdateDPIToCalculateByResources(jobId, equipmentList, employeeList); } if (null != addedResource && addedResource.Count > 0) GenerateAutomaticCallEntryAdd(jobId, username, addedResource, callDate); foreach (CS_Resource resource in addedResource) resourceSaved.Add(resource); foreach (CS_Resource resource in updatedResource) resourceSaved.Add(resource); EquipmentModel equipmentModel = new EquipmentModel(_unitOfWork); IList<CS_EquipmentPermit> permitList = equipmentModel.ListExpiredPermitByResourceList(resourceSaved.Where(e => e.EquipmentID.HasValue).ToList()); equipmentModel.SendNotificationForTransportationTeam(permitList); } return resourceSaved; }