public void GetNumberOfUnits_ReturnsACorrectNumberOfUnits() { // Arrange var units = new List <Unit> { new Unit() { Name = "TestUnit1", Id = 1, Code = "TU1" }, new Unit() { Name = "TestUnit2", Id = 2, Code = "TU2" }, }.AsQueryable(); var mockUnitDbSet = new Mock <DbSet <Unit> >(); mockUnitDbSet.As <IQueryable <Unit> >().Setup(m => m.Provider).Returns(units.Provider); mockUnitDbSet.As <IQueryable <Unit> >().Setup(m => m.Expression).Returns(units.Expression); mockUnitDbSet.As <IQueryable <Unit> >().Setup(m => m.ElementType).Returns(units.ElementType); mockUnitDbSet.As <IQueryable <Unit> >().Setup(m => m.GetEnumerator()).Returns(units.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(x => x.Units).Returns(mockUnitDbSet.Object); var unitBusiness = new UnitBusiness(mockContext.Object); // Act int expectedCount = 2; int actualCount = unitBusiness.GetNumberOfUnits(); // Assert Assert.AreEqual(expectedCount, actualCount, "Count is not the same."); }
public bool Confirm() { try { //remove equipe caso tipo de Fora de Serviço seja não operacional, desde que não seja por equipe incompleta if (!string.IsNullOrEmpty(SelectedOutType.OutServiceTypeId) && SelectedOutType.OutServiceTypeId.StartsWith("NO") && !SelectedOutType.OutServiceTypeId.Equals("NO_EQI") && !SelectedOutType.OutServiceTypeId.Equals("NO_SEQ")) { if (!ShowConfirmMessage("Colocar uma AM como 'Não Operacional' fará ela PERDER SUA EQUIPE. Deseja realmente continuar?")) { return(false); } UnitBusiness.LogOutAllMembers(UnitId); UnitForceMapBusiness.LogOutAllMembers(UnitId); UnitForceMapBusiness.RemoveSubstituteUnit(UnitId); } int alarmTime = (string.IsNullOrEmpty(AlarmTime) ? 0 : int.Parse(AlarmTime)); Location = (string.IsNullOrEmpty(Location) ? string.Empty : Location); double?mileage = (string.IsNullOrEmpty(Mileage) ? null : (double?)double.Parse(Mileage)); UnitBusiness.UnitOutOfService(UnitId, SelectedOutType.OutServiceTypeId, Location, alarmTime, mileage, Remarks); return(true); } catch { ShowMessage("Falha ao realizar solicitação"); } return(false); }
/// <summary> /// Add units the first time the application is started or when /// the database is reset. /// </summary> private void AddUnitsIfTheyAreNotInTheDatabase() { var eazyCartContext = new EazyCartContext(); this.unitBusiness = new UnitBusiness(eazyCartContext); if (this.unitBusiness.GetNumberOfUnits() == 0) { this.unitBusiness.Add(1, "Unit", "UN"); this.unitBusiness.Add(2, "Kilogram", "KG"); this.unitBusiness.Add(3, "Litre", "L"); } }
// The following methods are responsible for updating information when it is changed. /// <summary> /// Updates the user control every time it is loaded. /// </summary> public void UpdateUserControl() { var eazyCartContext = new EazyCartContext(); this.productBusiness = new ProductBusiness(eazyCartContext); this.categoryBusiness = new CategoryBusiness(eazyCartContext); this.supplierBusiness = new SupplierBusiness(eazyCartContext); this.unitBusiness = new UnitBusiness(eazyCartContext); this.countryBusiness = new CountryBusiness(eazyCartContext); this.cityBusiness = new CityBusiness(eazyCartContext); this.ClearAndUpdateProductTab(); this.ClearAndUpdateDeliveryTab(); }
public void LoadReserveUnitList(string agencyId) { List <string> specialOutTypeList = new List <string>(); List <OutOfServiceTypeModel.OutOfServiceSpecialType> SpecialTypes = new List <OutOfServiceTypeModel.OutOfServiceSpecialType>() { OutOfServiceTypeModel.OutOfServiceSpecialType.NO_OPERATIONAL, OutOfServiceTypeModel.OutOfServiceSpecialType.TECH_STOP }; //if (_selectedOutServiceType != null) ReserveUnitList = UnitBusiness.GetNotAssignedUnits(agencyId).OrderBy(u => Int32.Parse(u)).ToList <string>(); }
private void MedicineManagerForm_Load(object sender, EventArgs e) { // Load Medicine table gridCMedicineList.DataSource = medicineBusiness.GetAll(); //Load table to show on looktupedit MedicineType MedicineTypeBusiness medicineTypeBusiness = new MedicineTypeBusiness(); LookUpType.DataSource = medicineTypeBusiness.GetAll(); // Set data source LookUpType.ValueMember = "MedicineTypeID"; // Set value to save db LookUpType.DisplayMember = "MedicineTypeName"; //Set value to display //Add column to chose //LookUpType.Columns.Add(new LookUpColumnInfo("MedicineTypeID", "Mã loại thuốc")); LookUpType.Columns.Add(new LookUpColumnInfo("MedicineTypeName", "Tên loại thuốc")); //WaytoUse WayToUseBusiness wayToUse = new WayToUseBusiness(); LookUpWay.DataSource = wayToUse.GetAll(); LookUpWay.ValueMember = "WayToUseID"; LookUpWay.DisplayMember = "WayToUseName"; LookUpWay.Columns.Add(new LookUpColumnInfo("WayToUseName", "Đường dùng")); //Pharamcy PharmacyTypeBusiness medicine = new PharmacyTypeBusiness(); LookUpPharmacy.DataSource = medicine.GetAll(); LookUpPharmacy.ValueMember = "PharmacyTypeID"; LookUpPharmacy.DisplayMember = "PharmacyTypeName"; LookUpPharmacy.Columns.Add(new LookUpColumnInfo("PharmacyTypeName", "Dạng bào chế")); //Unit UnitBusiness unit = new UnitBusiness(); LookUpUnit.DataSource = unit.GetAll(); LookUpUnit.ValueMember = "UnitID"; LookUpUnit.DisplayMember = "UnitName"; LookUpUnit.Columns.Add(new LookUpColumnInfo("UnitName", "Đơn vị")); // Load data for comboboxedit MedicinType // Add default row "Tất cả" DataTable datasource = medicineTypeBusiness.GetAll(); var row = datasource.NewRow(); row["MedicineTypeID"] = 0; row["MedicineTypeName"] = "Tất cả"; datasource.Rows.Add(row); lookUpEditType.Properties.DataSource = datasource; // Set data source lookUpEditType.Properties.ValueMember = "MedicineTypeID"; // Set value to save db lookUpEditType.Properties.DisplayMember = "MedicineTypeName"; //Set value to display //Add column to chose //LookUpType.Columns.Add(new LookUpColumnInfo("MedicineTypeID", "Mã loại thuốc")); lookUpEditType.Properties.Columns.Add(new LookUpColumnInfo("MedicineTypeName", "Chọn")); }
public ImportProductPresenter(IImportProductView view) { _business = new ImportProductBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Import> >()); _businessProduct = new ProductBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Product> >()); _view = view; Import import = new Import(); var units = new UnitBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Unit> >()).GetAll().ToList(); var manufacturers = new ManufacturerBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Manufacturer> >()).GetAll().ToList(); _model = new ImportProductModel(import); _view.InitView(_model); }
public FastInputProducts() { _productBusiness = new ProductBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Product> >()); _unitBusiness = new UnitBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Unit> >()); _manufacturerBusiness = new ManufacturerBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Manufacturer> >()); InitializeComponent(); _units = _unitBusiness.GetAll(); _manufacturers = _manufacturerBusiness.GetAll(); _units.ToList().ForEach(u => (dgvProducts.Columns["colUnit"] as DataGridViewComboBoxColumn).Items.Add(u)); (dgvProducts.Columns["colUnit"] as DataGridViewComboBoxColumn).DisplayMember = "Name"; _manufacturers.ToList().ForEach(u => (dgvProducts.Columns["colManufacturer"] as DataGridViewComboBoxColumn).Items.Add(u)); (dgvProducts.Columns["colManufacturer"] as DataGridViewComboBoxColumn).DisplayMember = "Name"; }
public void Add_SuccessfullyAddsAnUnit() { // Arrange var mockUnitDbSet = new Mock <DbSet <Unit> >(); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(m => m.Units).Returns(mockUnitDbSet.Object); var unitBusiness = new UnitBusiness(mockContext.Object); // Act unitBusiness.Add(1, "TestUnit", "TU"); // Assert mockUnitDbSet.Verify(m => m.Add(It.IsAny <Unit>()), Times.Once()); mockContext.Verify(m => m.SaveChanges(), Times.Once()); }
public static void UpdateReportValidation(WorkScheduleImportTemplateModel workScheduleTemplate, List <WorkShiftModel> availableWorkshiftList, string currentAgencyId, ReportValidationModel repotValidationModel) { string returnMessage; List <string> validUnitList = new List <string>(); List <string> validStationIdList = new List <string>(); List <int> validEmployeeIdNumList = new List <int>(); List <string> validEmployeeIdList = new List <string>(); List <WorkScheduleUnitModel> workScheduleUnitList = new List <WorkScheduleUnitModel>(); validUnitList = UnitBusiness.GetActiveUnitsId(currentAgencyId); validStationIdList = CadBusiness.GetCadStationList(currentAgencyId).Select(cs => cs.StationId).ToList <string>(); validEmployeeIdNumList = GetEmployeeIds(currentAgencyId); foreach (int emp in validEmployeeIdNumList) { validEmployeeIdList.Add(emp.ToString()); } List <DateTime> dateTimeListFromWorkSchedule = workScheduleTemplate.WorkScheduleForUnitList.Where(ws => ws.ShiftDate.HasValue).Select(ws => ws.ShiftDate.Value).Distinct().ToList <DateTime>(); List <string> workshifLabelListfromWorkSchedule = workScheduleTemplate.WorkScheduleForUnitList.Select(ws => ws.WorkshiftLabel).Distinct().ToList <string>(); workScheduleTemplate.UpdateReportValidationBasedOnNewData(ref repotValidationModel, validStationIdList, validEmployeeIdList, validUnitList, availableWorkshiftList); foreach (DateTime date in dateTimeListFromWorkSchedule) { foreach (WorkShiftModel workShift in availableWorkshiftList.Where(ws => workshifLabelListfromWorkSchedule.Contains(ws.Label))) { workScheduleUnitList = WorkScheduleBusiness.GetWorkScheduleList(null, date, workShift, WorkShiftModel.ShiftTime.Forward, (int)FilterTypeEnum.ALL, out returnMessage) .Where(uf => uf.Driver != null || uf.Doctor != null || uf.Nurse != null || uf.FirstAuxiliar != null || uf.SecondAuxiliar != null || uf.ThirdAuxiliar != null) .ToList <WorkScheduleUnitModel>(); workScheduleTemplate.UpdateReportValidationBasedOnOldData(ref repotValidationModel, availableWorkshiftList, workScheduleUnitList); } } repotValidationModel.JoinIdsOfReportValidationList(); UpdateWorkScheduleWithErrors(repotValidationModel, workScheduleTemplate); if (repotValidationModel.ReportValidationItemList.Count == 0) { repotValidationModel.AddReportItem(WorkScheduleValidationType.VALIDATED, Properties.Resources.ALERT_MESSAGE_WHEN_NO_ERRORS); } }
public ProductPresenter(IProductView view) { if (Singleton <ProductBusiness> .Instance == null) { Singleton <ProductBusiness> .Instance = new ProductBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Product> >()); } _business = Singleton <ProductBusiness> .Instance; _businessPrice = new ProductPriceBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <ProductPrice> >()); _businessCategory = new CategoryBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Category> >()); _view = view; Product product = new Product(); var units = new UnitBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Unit> >()).GetAll().ToList(); var manufacturers = new ManufacturerBusiness(Singleton <PosEngine> .Instance.Resolve <IRepository <Manufacturer> >()).GetAll().ToList(); _model = new ProductModel(product, units, manufacturers); _view.InitView(_model); }
public void GetUnit_ReturnsAProduct_WhichIsNotNull() { // Arrange var units = new List <Unit> { new Unit() { Name = "TestUnit1", Id = 1, Code = "TU1" }, new Unit() { Name = "TestUnit2", Id = 2, Code = "TU2" }, }.AsQueryable(); var mockUnitDbSet = new Mock <DbSet <Unit> >(); mockUnitDbSet.As <IQueryable <Unit> >().Setup(m => m.Provider).Returns(units.Provider); mockUnitDbSet.As <IQueryable <Unit> >().Setup(m => m.Expression).Returns(units.Expression); mockUnitDbSet.As <IQueryable <Unit> >().Setup(m => m.ElementType).Returns(units.ElementType); mockUnitDbSet.As <IQueryable <Unit> >().Setup(m => m.GetEnumerator()).Returns(units.GetEnumerator()); var mockContext = new Mock <EazyCartContext>(); mockContext.Setup(x => x.Units).Returns(mockUnitDbSet.Object); var unitBusiness = new UnitBusiness(mockContext.Object); // Act int idToGet = 1; string expectedUnitName = "TestUnit1"; var unit = unitBusiness.Get(idToGet); // Assert Assert.IsNotNull(unit, "Unit could not be extracted"); Assert.AreEqual(expectedUnitName, unit.Name, "Name is not the same."); }
public UnitForm() { InitializeComponent(); unitBusiness = new UnitBusiness(); }
public UnitController(UnitBusiness propertyBusiness) { _unitBusiness = propertyBusiness; }
public ResidentController(ResidentBusiness residentBusiness, UserBusiness userBusiness, UnitBusiness unitBusiness) { _residentBusiness = residentBusiness; _userBusiness = userBusiness; _unitBusiness = unitBusiness; }
public bool LoginOutServiceUnit() { try { if (string.IsNullOrEmpty(SelectedTargetUnitId)) { MessageBox.Show("Favor selecionar a AM que entrará em serviço.", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { //VERIFICAR SE A UNIDADE POSSUI CNES, NÃO É POSSÍVEL LOGAR UMA VIATURA QUE NÃO POSSUA CNES CADASTRADO. string currentUnitCnes = UnitForceMapBusiness.GetUnitCnes(SelectedTargetUnitId); if (string.IsNullOrEmpty(currentUnitCnes)) { MessageBox.Show("Não foi possível logar a AM pois nao existe um CNES cadastrado para a mesma.", "Atenção!", MessageBoxButton.OK, MessageBoxImage.Exclamation); return(false); } string substituteUnitId = UnitForceMapBusiness.GetSubstituteUnitId(SelectedTargetUnitId); if (!string.IsNullOrEmpty(substituteUnitId)) { //A UNIDADE SELECTIONADA POSSUI CNES, PORÉM ESTÁ SENDO SUBSTITUÍDA NO MOMENTO POR UMA OUTRA VIATURA, //PRECISA VERIFICAR SE ESSA OUTRA VIATURA TAMBÉM POSSUI CNES ANTES DE PERGUNTAR SOBRE A RETIRADA DO VÍNCULO. string substituteUnitCnes = UnitForceMapBusiness.GetUnitCnes(substituteUnitId); if (string.IsNullOrEmpty(substituteUnitCnes)) { MessageBox.Show(string.Format("A unidade {0} está atuando como reserva da selecionada, {1}." + Environment.NewLine + "Não é possível colocar a viatura {1} em operação, pois sua reserva {0} não possui um CNES cadastrado." + Environment.NewLine + "Substitua a viatura reserva pela oficial caso deseje o retorno da viatura {1} de volta em operação.", substituteUnitId, SelectedTargetUnitId), "Viatura possui unidade reserva em operação", MessageBoxButton.OK); return(false); } if (UnitBusiness.IsAssigned(substituteUnitId)) { MessageBox.Show(string.Format("A unidade {0}, que está substituindo a selecionada, está EMPENHADA." + Environment.NewLine + "Não é possível colocá-la em serviço.", substituteUnitId), "Viatura possui reserva empenhada", MessageBoxButton.OK); return(false); } MessageBoxResult msgBoxResult = MessageBox.Show(string.Format("A unidade {0} está atuando como reserva da selecionada, {1}." + Environment.NewLine + "Deseja remover o vínculo entre elas e manter as duas em operação?", substituteUnitId, SelectedTargetUnitId), "Viatura possui unidade reserva em operação", MessageBoxButton.OKCancel); if (msgBoxResult == MessageBoxResult.OK) {//string _outServiceTypeId UnitForceMapModel unitForceTarget = UnitForceMapBusiness.GetCurrentUnitForceMap(SelectedTargetUnitId); UnitForceMapModel unitForceCurrent = UnitForceMapBusiness.GetCurrentUnitForceMap(substituteUnitId); OutOfServiceTypeModel outOfServiceType = UnitForceMapBusiness.GetOutOfServiceType(OutOfServiceTypeModel.OUT_TYPE_RESERVA_TECNICA_ID, "SAMU"); UnitForceMapBusiness.ExchangeUnit(unitForceCurrent, unitForceTarget, outOfServiceType); //UnitForceMapBusiness.RemoveSubstituteUnit(SelectedTargetUnitId); //LoginSelectedUnit(); return(true); } } else { LoginSelectedUnit(); return(true); } } } catch (Exception) { ShowErrorMessage(); } return(false); }
public bool LoadData() { try { //INICIALMENTE SETADO COMO NÃO ENCONTRADO, ABAIXO SE ENCONTRAR REGISTRO SETA PARA OUTRO. this.EventSituation = EventSituationEnum.NotFound; this.VictimData = new VictimModel(); this.ReasonList = EventTypeBusiness.GetDispositionCodeList(true); if (this.ReasonList.Count == 0) { return(false); } this.SituationFoundList = EventTypeBusiness.GetEventTypeList(); this.HospitalList = SamuBusiness.GetHospitalList(); this.DisplayHospitalList = HospitalList; this.IsNotUram = (UnitBusiness.GetUnitType(this.UnitId) != "URAM"); UnitWithRetainedStretcherModel unitWithRetainedStretcher = null; //TODO: Temporário: Voltar para ativar recurso de Maca Retida /* RetainedStretcherBusiness.GetUnitsWithRetainedStretcher("SAMU", PersonBusiness.GetCurrentUser(), this.UnitId, isOnlyWithStatusRetainedStretcher: false) * .FirstOrDefault();*/ this.HasNotRetainedStretcher = unitWithRetainedStretcher == null ? true : false; HospitalTypeList = HospitalList.Select(p => p.HospitalGroup).Distinct().ToList(); _dispositionNotFoundTypeCode = CadBusiness.GetCadParameterListItem("sisgraph", "SubmissionWindowParams", "DispositionNotFoundCode"); _dispositionRemovedTypeCode = CadBusiness.GetCadParameterListItem("sisgraph", "SubmissionWindowParams", "DispositionRemovedCode"); //_dispositionRetainedStretcher = CadBusiness.GetCadParameterListItem("sisgraph", "SubmissionWindowParams", "DispositionRetainedStretcher"); if (_dispositionNotFoundTypeCode == null || _dispositionRemovedTypeCode == null) //|| _dispositionRetainedStretcher == null { throw new Exception("Não foi possível carregar os parâmetros do ICAD."); } if (_isSubmitted) { SubmissionModel loadedSubmissionModel = SubmissionBusiness.GetLoadedSubmission(UnitId, AgencyEventId); if (loadedSubmissionModel == null) { //{ // throw new Exception("Dados de finalização não encontrados."); //} loadedSubmissionModel = new SubmissionModel(); loadedSubmissionModel.DispositionCode = _dispositionRemovedTypeCode; this.EventSituation = EventSituationEnum.Removed; this.HospitalHasChanged = true; } else { //ToString: complete if (loadedSubmissionModel.DispositionCode == _dispositionNotFoundTypeCode) { this.EventSituation = EventSituationEnum.NotFound; } else if (loadedSubmissionModel.DispositionCode == _dispositionRemovedTypeCode) { this.EventSituation = EventSituationEnum.Removed; } //else if (loadedSubmissionModel.DispositionCode == _dispositionRetainedStretcher) // this.EventSituation = EventSituationEnum.RetainedStretcher; else { this.EventSituation = EventSituationEnum.ResolvedOnLocal; } this.SelectedReason = loadedSubmissionModel.SelectedReason; this.AsExpected = loadedSubmissionModel.AsExpected; this.VictimData = loadedSubmissionModel.Victim; if (!string.IsNullOrEmpty(loadedSubmissionModel.Victim.SituationFound.Key)) { this.VictimData.SituationFound = SituationFoundList.Where(p => p.Key == loadedSubmissionModel.Victim.SituationFound.Key).FirstOrDefault(); } if (loadedSubmissionModel.SelectedHospital != null) { this.SelectedHospitalType = loadedSubmissionModel.SelectedHospital.HospitalGroup; this.SelectedHospital = HospitalList.Where(p => p.Cnes == loadedSubmissionModel.SelectedHospital.Cnes).FirstOrDefault(); } this.Remarks = loadedSubmissionModel.Remarks; } } return(true); } catch (Exception ex) { logger.Error("Ocorreu um erro carregando a ViewModel da janela de finalização de evento.", ex); throw new Exception("Falha ao carregar dados de finalização"); } }
public UnitController(PropertyBusiness propertyBusiness, UnitBusiness unitBusiness) { _propertyBusiness = propertyBusiness; _unitBusiness = unitBusiness; }