public DoctorController(DrugstoreDbContext context, UserManager <SystemUser> userManager, GetPrescriptionsListUseCase getPrescriptions, GetPrescriptionDetailsUseCase getPrescriptionDetails, GetPrescriptionUseCase getPrescription, GetMedicinesUseCase getMedicines, GetPatientsUseCase getPatients, DeletePrescriptionUseCase deletePrescription, GetTreatmentHistoryUseCase getTreatmentHistory, GetPrescriptionMedicinesUseCase getPrescriptionMedicines, EditPrescriptionUseCase editPrescription, AddPrescriptionUseCase addPrescription) { this.context = context; this.userManager = userManager; this.getPrescription = getPrescription; this.getMedicines = getMedicines; this.getPatients = getPatients; this.deletePrescription = deletePrescription; this.getTreatmentHistory = getTreatmentHistory; this.getPrescriptionMedicines = getPrescriptionMedicines; this.editPrescription = editPrescription; this.addPrescription = addPrescription; getPrescriptionsList = getPrescriptions; this.getPrescriptionDetails = getPrescriptionDetails; }
public static Dictionary <int, int> CreateProductList(DrugstoreDbContext context) { DateTime currentDay = DateTime.Today; var obj = context.ExternalDrugstoreSoldMedicines.Include(d => d.StockMedicine); //This list contains todays order List var orderList = obj.Where(d => d.Date >= currentDay); DateTime lastSevenDays = DateTime.Today; //This list contains every medicines that have been sold at least 7 day ago lastSevenDays = DateTime.Today.AddDays(-7); var historyList = obj.Where(d => d.Date >= lastSevenDays); var dictionary = new Dictionary <int, int>(); foreach (var product in orderList) { var average = 0; var sum = 0; var quantity = 0; foreach (var historyProduct in historyList) { if (historyProduct.StockMedicine.ID == product.StockMedicine.ID) { sum += historyProduct.SoldQuantity; quantity++; } } average = (sum / quantity) < product.SoldQuantity ? product.SoldQuantity : (sum / quantity); dictionary.Add(product.Id, average); } return(dictionary); }
public void SetUp() { MapperDependencyResolver.Resolve(); context = new DrugstoreDbContext(options); #region Data seed var stockMed = new MedicineOnStock { MedicineCategory = MedicineCategory.Special, PricePerOne = 30, Quantity = 50, Refundation = 0.20, Name = "Lek testowy" }; var doctor = new Doctor { FirstName = "Testowy", SecondName = "Lekarz" }; var patient = new Patient { FirstName = "Testowy", SecondName = "Pacjent" }; context.Doctors.Add(doctor); context.Patients.Add(patient); context.Medicines.Add(stockMed); context.SaveChanges(); #endregion }
public AdminUseCase( UserManager <SystemUser> userManager, RoleManager <IdentityRole> roleManager, DrugstoreDbContext drugstoreDbContext) { this.userManager = userManager; this.roleManager = roleManager; context = drugstoreDbContext; }
public NurseController( DrugstoreDbContext context, NurseUseCase nurseUseCase, UserManager <SystemUser> userManager) { this.context = context; this.nurseUseCase = nurseUseCase; this.userManager = userManager; pdfCreator = new PdfCreator(); }
public PostXMLStoreOrderListUseCase( DrugstoreDbContext context, ILogger <PostXMLStoreOrderListUseCase> logger, ISerializer <MemoryStream, XmlMedicineSupplyModel> serializer, ICopy fileCopy) { this.context = context; this.logger = logger; this.serializer = serializer; this.fileCopy = fileCopy; }
public UploadSoldMedicinesListUseCase( DrugstoreDbContext context, ILogger <UploadSoldMedicinesListUseCase> logger, ISerializer <MemoryStream, XmlMedicineSupplyModel> serializer, ICopy fileCopy) { this.context = context; this.logger = logger; this.serializer = serializer; this.fileCopy = fileCopy; }
public PatientController( UserManager <SystemUser> userManager, DrugstoreDbContext context, GetTreatmentOverviewDataUseCase getTreatmentOverviewDataUseCase, GetPrescriptionDetailsUseCase getPrescriptionDetailsUseCase) { this.userManager = userManager; this.context = context; this.getTreatmentOverviewDataUseCase = getTreatmentOverviewDataUseCase; this.getPrescriptionDetailsUseCase = getPrescriptionDetailsUseCase; }
public InternalPharmacistController( DrugstoreDbContext context, GetUnverifiedPrescriptionsUseCase getUnverifiedPrescriptions, GetPrescriptionUseCase getPrescription, AcceptPrescriptionUseCase acceptPrescription, RejectPrescriptionUseCase rejectPrescription) { this.context = context; this.getUnverifiedPrescriptions = getUnverifiedPrescriptions; this.getPrescription = getPrescription; this.acceptPrescription = acceptPrescription; this.rejectPrescription = rejectPrescription; }
public void SetUp() { MapperDependencyResolver.Resolve(); context = new DrugstoreDbContext(options); #region Data seed var stockMed = new MedicineOnStock { MedicineCategory = MedicineCategory.Special, PricePerOne = 30, Quantity = 50, Refundation = 0.20, Name = "Lek testowy" }; var doctor = new Doctor { FirstName = "Testowy", SecondName = "Lekarz" }; var patient = new Patient { FirstName = "Testowy", SecondName = "Pacjent" }; var prescription = new MedicalPrescription { CreationTime = DateTime.Now, Doctor = doctor, Patient = patient, VerificationState = VerificationState.NotVerified, Medicines = new List <AssignedMedicine> { new AssignedMedicine { StockMedicine = stockMed, PricePerOne = stockMed.PricePerOne * (1 - stockMed.Refundation), AssignedQuantity = 10 } } }; context.Doctors.Add(doctor); context.Patients.Add(patient); context.Medicines.Add(stockMed); context.MedicalPrescriptions.Add(prescription); context.SaveChanges(); #endregion }
public AdminTests() { options = new DbContextOptionsBuilder <DrugstoreDbContext>() .UseInMemoryDatabase(databaseName: "Drugstore_Admin").Options; var userStoreMock = new Mock <IUserStore <SystemUser> >(); var userManagerMock = new Mock <UserManager <SystemUser> >(userStoreMock.Object, null, null, null, null, null, null, null, null); var roleManagerMock = new Mock <RoleManager <IdentityRole> >( new Mock <IRoleStore <IdentityRole> >().Object, new IRoleValidator <IdentityRole> [0], new Mock <ILookupNormalizer>().Object, new Mock <IdentityErrorDescriber>().Object, new Mock <ILogger <RoleManager <IdentityRole> > >().Object); var passwordHasherMock = new Mock <IPasswordHasher <SystemUser> >(); passwordHasherMock.Setup(p => p.HashPassword(It.IsAny <SystemUser>(), It.IsAny <string>())) .Returns("password"); userManagerMock.Object.PasswordHasher = passwordHasherMock.Object; userManagerMock.Setup(u => u.CreateAsync(It.IsAny <SystemUser>())) .Returns(Task <IdentityResult> .FromResult(new IdentityResult())); userManagerMock.Setup(u => u.AddToRoleAsync(It.IsAny <SystemUser>(), It.IsAny <string>())) .Returns(Task <IdentityResult> .FromResult(new IdentityResult())); userManagerMock.Setup(u => u.FindByIdAsync(It.IsAny <string>())) .Returns(Task.FromResult <SystemUser>(new SystemUser())); userManagerMock.Setup(u => u.GetRolesAsync(It.IsAny <SystemUser>())) .Returns(Task.FromResult <IList <string> >(new string [] { "Admin" })); userManagerMock.Setup(u => u.DeleteAsync(It.IsAny <SystemUser>())) .Returns(Task.FromResult <IdentityResult>(new IdentityResult())); context = new DrugstoreDbContext(options); useCase = new AdminUseCase(userManagerMock.Object, roleManagerMock.Object, context); }
public AcceptPrescriptionUseCase(DrugstoreDbContext context, ILogger <AcceptPrescriptionUseCase> logger) { this.context = context; this.logger = logger; }
public GetTreatmentOverviewDataUseCase(DrugstoreDbContext context) { this.context = context; }
public GetPatientsUseCase(DrugstoreDbContext context) { this.context = context; }
public GetPrescriptionDetailsUseCase(DrugstoreDbContext context) { this.context = context; }
public GetPrescriptionsListUseCase(DrugstoreDbContext context) { this.context = context; }
public void SetUp() { MapperDependencyResolver.Resolve(); context = new DrugstoreDbContext(options); #region Data seed var stockMedOne = new MedicineOnStock { MedicineCategory = MedicineCategory.Special, PricePerOne = 30, Quantity = 50, Refundation = 0.20, Name = "Lek testowy" }; var stockMedTwo = new MedicineOnStock { MedicineCategory = MedicineCategory.Normal, PricePerOne = 20, Quantity = 100, Refundation = 0.60, Name = "Voltaren" }; var doctor = new Doctor { FirstName = "Testowy", SecondName = "Lekarz" }; var patientOne = new Patient { FirstName = "Pacjentka", SecondName = "One" }; var patientTwo = new Patient { FirstName = "Pacjent", SecondName = "Two" }; var prescriptions = new MedicalPrescription [] { new MedicalPrescription { CreationTime = DateTime.Parse("2019/01/20"), Doctor = doctor, Patient = patientOne, VerificationState = VerificationState.NotVerified, Medicines = new List <AssignedMedicine> { new AssignedMedicine { StockMedicine = stockMedOne, PricePerOne = stockMedOne.PricePerOne * (1 - stockMedOne.Refundation), AssignedQuantity = 10 } } }, new MedicalPrescription { CreationTime = DateTime.Parse("2019/01/22"), Doctor = doctor, Patient = patientOne, VerificationState = VerificationState.NotVerified, Medicines = new List <AssignedMedicine> { new AssignedMedicine { StockMedicine = stockMedTwo, PricePerOne = stockMedTwo.PricePerOne * (1 - stockMedTwo.Refundation), AssignedQuantity = 10 } } }, new MedicalPrescription { CreationTime = DateTime.Parse("2019/01/28"), Doctor = doctor, Patient = patientTwo, VerificationState = VerificationState.Accepted, Medicines = new List <AssignedMedicine> { new AssignedMedicine { StockMedicine = stockMedOne, PricePerOne = stockMedOne.PricePerOne * (1 - stockMedOne.Refundation), AssignedQuantity = 10 } } }, new MedicalPrescription { CreationTime = DateTime.Parse("2019/01/30"), Doctor = doctor, Patient = patientTwo, VerificationState = VerificationState.Accepted, Medicines = new List <AssignedMedicine> { new AssignedMedicine { StockMedicine = stockMedTwo, PricePerOne = stockMedTwo.PricePerOne * (1 - stockMedTwo.Refundation), AssignedQuantity = 10 } } } }; context.Doctors.Add(doctor); context.Patients.Add(patientTwo); context.Medicines.Add(stockMedOne); context.Medicines.Add(stockMedTwo); context.MedicalPrescriptions.AddRange(prescriptions); context.SaveChanges(); #endregion }
public GetTreatmentHistoryUseCase(DrugstoreDbContext context) { this.context = context; }
public GetMedicinesUseCase(DrugstoreDbContext context) { this.context = context; }
public NurseUseCase(DrugstoreDbContext context, UserManager <SystemUser> userManager) { this.context = context; this.userManager = userManager; }
public GetPrescriptionMedicinesUseCase(DrugstoreDbContext context) { this.context = context; }
public AdminController(AdminUseCase adminUseCase, DrugstoreDbContext drugstore, UserManager <SystemUser> userManager) { this.adminUseCase = adminUseCase; this.drugstore = drugstore; this.userManager = userManager; }
public void SetUp() { //dateProvider.AddDays(-1); MapperDependencyResolver.Resolve(); context = new DrugstoreDbContext(options); var med1 = new Core.MedicineOnStock { MedicineCategory = Core.MedicineCategory.Normal, Name = "First Medicine", PricePerOne = 25.66, Quantity = 100, Refundation = 0.2 }; var med2 = new Core.MedicineOnStock { MedicineCategory = Core.MedicineCategory.Normal, Name = "Second Medicine", PricePerOne = 6.66, Quantity = 100, Refundation = 0.1 }; var med3 = new Core.MedicineOnStock { MedicineCategory = Core.MedicineCategory.Normal, Name = "Third Medicine", PricePerOne = 22.66, Quantity = 100, Refundation = 0.25 }; var med4 = new Core.MedicineOnStock { MedicineCategory = Core.MedicineCategory.Normal, Name = "fourth Medicine", PricePerOne = 25.66, Quantity = 40, Refundation = 0.2 }; var med5 = new Core.MedicineOnStock { MedicineCategory = Core.MedicineCategory.Normal, Name = "fifth Medicine", PricePerOne = 26.66, Quantity = 10, Refundation = 0.1 }; var med6 = new Core.MedicineOnStock { MedicineCategory = Core.MedicineCategory.Normal, Name = "sixth Medicine", PricePerOne = 24.66, Quantity = 100, Refundation = 0.25 }; context.Medicines .AddRange(new Core.MedicineOnStock [] { med1, med2, med3, med4, med5, med6 }); context.SaveChanges(); var exMed1 = new Core.ExternalDrugstoreMedicine { StockMedicine = med1, Name = med1.Name, PricePerOne = med1.PricePerOne, Quantity = 50, }; var exMed2 = new Core.ExternalDrugstoreMedicine { StockMedicine = med2, Name = med2.Name, PricePerOne = med2.PricePerOne, Quantity = 50, }; var exMed3 = new Core.ExternalDrugstoreMedicine { StockMedicine = med3, Name = med3.Name, PricePerOne = med3.PricePerOne, Quantity = 50, }; var exMed4 = new Core.ExternalDrugstoreMedicine { StockMedicine = med4, Name = med4.Name, PricePerOne = med4.PricePerOne, Quantity = 50, }; var exMed5 = new Core.ExternalDrugstoreMedicine { StockMedicine = med5, Name = med5.Name, PricePerOne = med5.PricePerOne, Quantity = 50, }; var exMed6 = new Core.ExternalDrugstoreMedicine { StockMedicine = med6, Name = med6.Name, PricePerOne = med6.PricePerOne, Quantity = 50, }; context.ExternalDrugstoreMedicines .AddRange(new Core.ExternalDrugstoreMedicine [] { exMed1, exMed2, exMed3, exMed4, exMed5, exMed6 }); context.SaveChanges(); //dodane dzisiaj var sold1 = new ExternalDrugstoreSoldMedicine { StockMedicine = med1, PricePerOne = med1.PricePerOne, Date = dateProvider, SoldQuantity = 5 }; var sold2 = new ExternalDrugstoreSoldMedicine { StockMedicine = med2, PricePerOne = med2.PricePerOne, Date = dateProvider, SoldQuantity = 20 }; var sold3 = new ExternalDrugstoreSoldMedicine { StockMedicine = med3, PricePerOne = med3.PricePerOne, Date = dateProvider, SoldQuantity = 1 }; dateProvider = DateTime.Today.AddDays(-1); //wczoraj var sold4 = new ExternalDrugstoreSoldMedicine { StockMedicine = med1, PricePerOne = med1.PricePerOne, Date = dateProvider, SoldQuantity = 2 }; var sold5 = new ExternalDrugstoreSoldMedicine { StockMedicine = med2, PricePerOne = med2.PricePerOne, Date = dateProvider, SoldQuantity = 24 }; var sold6 = new ExternalDrugstoreSoldMedicine { StockMedicine = med3, PricePerOne = med3.PricePerOne, Date = dateProvider, SoldQuantity = 36 }; dateProvider = DateTime.Today.AddDays(-2); // te nizej beda sprzed 2 dni var sold7 = new ExternalDrugstoreSoldMedicine { StockMedicine = med1, PricePerOne = med1.PricePerOne, Date = dateProvider, SoldQuantity = 3 }; var sold8 = new ExternalDrugstoreSoldMedicine { StockMedicine = med2, PricePerOne = med2.PricePerOne, Date = dateProvider, SoldQuantity = 11 }; var sold9 = new ExternalDrugstoreSoldMedicine { StockMedicine = med3, PricePerOne = med3.PricePerOne, Date = dateProvider, SoldQuantity = 12 }; dateProvider = DateTime.Today.AddDays(-7); // te nizej beda sprzed 7 dni, powinny byc var sold17 = new ExternalDrugstoreSoldMedicine { StockMedicine = med1, PricePerOne = med1.PricePerOne, Date = dateProvider, SoldQuantity = 30 }; var sold18 = new ExternalDrugstoreSoldMedicine { StockMedicine = med2, PricePerOne = med2.PricePerOne, Date = dateProvider, SoldQuantity = 5 }; var sold19 = new ExternalDrugstoreSoldMedicine { StockMedicine = med3, PricePerOne = med3.PricePerOne, Date = dateProvider, SoldQuantity = 47 }; dateProvider = DateTime.Today.AddDays(-8); //daaawno temu, nie powinno byc tego na liscie var sold10 = new ExternalDrugstoreSoldMedicine { StockMedicine = med1, PricePerOne = med1.PricePerOne, Date = dateProvider, SoldQuantity = 10 }; var sold11 = new ExternalDrugstoreSoldMedicine { StockMedicine = med2, PricePerOne = med2.PricePerOne, Date = dateProvider, SoldQuantity = 10 }; var sold12 = new ExternalDrugstoreSoldMedicine { StockMedicine = med3, PricePerOne = med3.PricePerOne, Date = dateProvider, SoldQuantity = 10 }; context.ExternalDrugstoreSoldMedicines .AddRange(new ExternalDrugstoreSoldMedicine [] { sold1, sold2, sold3, sold4, sold5, sold6, sold7, sold8, sold9, sold10, sold11, sold12, sold17, sold18, sold19 }); context.SaveChanges(); }
public GetUnverifiedPrescriptionsUseCase(DrugstoreDbContext context, int pageSize = 5) { this.context = context; this.pageSize = pageSize; }
public GetPrescriptionDetailsUseCase(DrugstoreDbContext context, ILogger <GetPrescriptionDetailsUseCase> logger) { this.context = context; this.logger = logger; }
public void SetUp() { MapperDependencyResolver.Resolve(); context = new DrugstoreDbContext(options); var med1 = new Core.MedicineOnStock { MedicineCategory = Core.MedicineCategory.Normal, Name = "F;irst Medicine", PricePerOne = 25.66, Quantity = 100, Refundation = 0.2 }; var med2 = new Core.MedicineOnStock { MedicineCategory = Core.MedicineCategory.Normal, Name = "Second Medicine", PricePerOne = 6.66, Quantity = 100, Refundation = 0.1 }; var med3 = new Core.MedicineOnStock { MedicineCategory = Core.MedicineCategory.Normal, Name = "Third Medicine", PricePerOne = 22.66, Quantity = 100, Refundation = 0.25 }; context.Medicines .AddRange(new Core.MedicineOnStock [] { med1, med2, med3 }); context.SaveChanges(); var exMed1 = new Core.ExternalDrugstoreMedicine { StockMedicine = med1, Name = med1.Name, PricePerOne = med1.PricePerOne, Quantity = initialQuantity, }; var exMed2 = new Core.ExternalDrugstoreMedicine { StockMedicine = med2, Name = med2.Name, PricePerOne = med2.PricePerOne, Quantity = initialQuantity, }; var exMed3 = new Core.ExternalDrugstoreMedicine { StockMedicine = med3, Name = med3.Name, PricePerOne = med3.PricePerOne, Quantity = initialQuantity, }; context.ExternalDrugstoreMedicines .AddRange(new Core.ExternalDrugstoreMedicine [] { exMed1, exMed2, exMed3 }); context.SaveChanges(); var sold1 = new ExternalDrugstoreSoldMedicine { StockMedicine = med1, PricePerOne = med1.PricePerOne, Date = DateTime.Now, SoldQuantity = 10 }; var sold2 = new ExternalDrugstoreSoldMedicine { StockMedicine = med2, PricePerOne = med2.PricePerOne, Date = DateTime.Now, SoldQuantity = 10 }; var sold3 = new ExternalDrugstoreSoldMedicine { StockMedicine = med3, PricePerOne = med3.PricePerOne, Date = DateTime.Now, SoldQuantity = 10 }; context.ExternalDrugstoreSoldMedicines .AddRange(new ExternalDrugstoreSoldMedicine [] { sold1, sold2, sold3 }); context.SaveChanges(); supply = new XmlMedicineSupplyModel { Medicines = new List <XmlMedicineModel> { new XmlMedicineModel { StockId = med1.ID, Quantity = 10, }, new XmlMedicineModel { StockId = med2.ID, Quantity = 10, }, new XmlMedicineModel { StockId = med3.ID, Quantity = 20, } } }; }
public DeletePrescriptionUseCase(DrugstoreDbContext context, ILogger <DeletePrescriptionUseCase> logger) { this.context = context; this.logger = logger; }