public ActionResult UpdateDatabase(string file1) { // convert string to stream byte[] byteArray = Encoding.UTF8.GetBytes(file1); //this one //byte[] byteArray = Encoding.ASCII.GetBytes(file); MemoryStream stream = new MemoryStream(byteArray); //Upload CSV here try { InitDatabaseService init = new InitDatabaseService(); //init.Reset(); //this is bad, we need to check for duplicates, not drop the tables Pharmacy pharm = User.getPharmacy(); init.LoadFromMemoryStream(stream, pharm); using (var PharmacistService = new PharmacistService()) using (var service = new PharmacyService()) { pharm.LastUploaded = DateTime.Now.ToUniversalTime(); //pharm.LastUploader = PharmacistService.Get(User.Code); service.Update(pharm); } } catch (Exception ex) { Console.WriteLine(ex); return(Json(ex)); } return(null); }
public ActionResult AddPharmacist(int PharmacyCode, string FirstName, string LastName, string Email, string Phone, bool IsAdmin = false, bool IsActive = false) { using (var service = new PharmacistService()) { Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", ""); if (Phone.Length == 10) { Phone = "1" + Phone; } Pharmacist p = service.GetWhere(PharmacistService.EmailCol == Email).FirstOrDefault(); if (p == null) { p = new Pharmacist(FirstName, LastName, Email, Phone, new byte[] { 0 }, new byte[] { 0 }); service.Create(p); } Pharmacy pharm; using (var pharmservice = new PharmacyService()) { pharm = pharmservice.Get(PharmacyCode); } using (var jobservice = new JobService()) { Job j = new Job(pharm, p, IsActive, IsAdmin); jobservice.Create(j); } } using (var service = new EmailService()) { service.SendEmail(Email, newAccountEmailSubject, newAccountEmailBody); } return(RedirectToAction("SinglePharmacy", new RouteValueDictionary( new { controller = "SystemAdmin", action = "SinglePharmacy", Id = PharmacyCode }))); }
public PPOKPrincipal(Pharmacist pharmacist, int pharmacyCode) : base() { Identity = new GenericIdentity(pharmacist.Email); Code = pharmacist.Code; FirstName = pharmacist.FirstName; LastName = pharmacist.LastName; Phone = pharmacist.Phone; Email = pharmacist.Email; using (var service = new PharmacyService()) { Pharmacy = service.Get(pharmacyCode); } Type = AccountTypes.Pharmacist; foreach (var job in pharmacist.Jobs.Where(x => x.Pharmacy.Code == Pharmacy.Code)) { if (job.IsActive) { if (job.IsAdmin) { addRole("Admin"); Type = AccountTypes.Admin; } addRole("Pharmacist"); } } }
private async void OpenPage() { KooshDarooDatabase odb = new KooshDarooDatabase(); var oLoginItemS = odb.GetPharmacysAsync(); if (oLoginItemS.Result.Count > 0) { PharmacyService Pharmacyervices = new PharmacyService(); var pharmacyS = Task.Run(() => Pharmacyervices.GetPharmacyByPhoneNoAsync(oLoginItemS.Result[0].PhoneNo)); if (pharmacyS.Result.Count == 0) { oLoginItemS.Result.ForEach(f => odb.DeletePharmacyAsync(f)); MainPage = new NavigationPage(new SignUpPage()); //MainPage = new SignUpPage(); } else { myId = pharmacyS.Result[0].id; myPhoneNo = pharmacyS.Result[0].PhoneNo; MainPage = new NavigationPage(new MainPageTabbed()); //MainPage = new MainPageTabbed(); } } else { MainPage = new SignUpPage(); } }
public ActionResult AddPharmacist(string FirstName, string LastName, string Email, string Phone, bool IsActive = false, bool IsAdmin = false) { Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", ""); if (Phone.Length == 10) { Phone = "1" + Phone; } using (var service = new PharmacistService()) { Pharmacist p = service.GetWhere(PharmacistService.EmailCol == Email).FirstOrDefault(); if (p == null) { new Pharmacist(FirstName, LastName, Email, Phone, new byte[] { 0 }, new byte[] { 0 }); service.Create(p); } Pharmacy pharm; using (var pharmservice = new PharmacyService()) { pharm = pharmservice.Get(User.getPharmacy().Code); } using (var jobservice = new JobService()) { //these get the value, not the checked value Job j = new Job(pharm, p, IsActive, IsAdmin); jobservice.Create(j); } return(RedirectToAction("Pharmacy", new RouteValueDictionary( new { controller = "ManagePharmacist", action = "Pharmacy", Id = User.Pharmacy.Code }))); } }
public static void Test() { try { //EventRecallService init = new EventRecallService(); Console.WriteLine("Creating sample data..."); Pharmacy pharm = new Pharmacy(2, "test2", "test3", "test4"); using (var service = new PharmacyService()) { service.Update(pharm); } MessageTemplate temp = new MessageTemplate(pharm, MessageTemplateType.RECALL, MessageTemplateMedia.EMAIL, "this is a test"); using (var service = new MessageTemplateService()) { service.Update(temp); } Drug drug = new Drug(7, "Omeprazole Cap Delayed Release 20 MG"); using (var service = new DrugService()) { service.Update(drug); } Console.WriteLine("Samples created successfully.\nUploading patients..."); //init.SendRecalls(@"..\..\App_Data\RecallCSVTest.csv", pharm, temp, drug); Console.WriteLine("Patients uploaded successfully.\nAll tests successful..."); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadKey(); } }
public ActionResult SinglePharmacy(int id) { using (var service = new PharmacyService()) { var result = service.Get(id); return(View(result)); } }
public void Add_pharmacy() { PharmacyService pharmacyService = new PharmacyService(CreateStubRepository()); Pharmacies pharmacy = pharmacyService.AddEntity(new Pharmacies("NekaApoteka", "APi1", "nekilink1")); Assert.NotNull(pharmacy); }
public void Get_pharmacies() { PharmacyService pharmacyService = new PharmacyService(CreateStubRepository()); List <Pharmacies> results = (List <Pharmacies>)pharmacyService.GetAllEntities(); Assert.NotNull(results); }
public async void Registration() { if (IsNullOrWhiteSpaceExtension.AllIsNullOrWhiteSpace(false, FirstName, SecondName, Address, BornDate, Mail, Number)) { PharmacyService service = new PharmacyService(); UserInfo user = await service.Add(usr); await Navigation.PopToRootAsync(); } }
public ActionResult Pharmacy() { int id = User.Pharmacy.Code; //this id should be grabbed from the user to reflect current using (var service = new PharmacyService()) { var result = service.Get(id); return(View(result)); } }
public async Task FindClosestWhenPharmacyInputIsNull() { _pharmacyBuilderMock.Setup(x => x.FindClosestAsync(It.IsAny <PharmacyInputModel>())) .ReturnsAsync(new PharmacyModel()); _cacheRepositoryMock.Setup(x => x.GetByKeyAsync <PharmacyModel>(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(new PharmacyModel()); var pharmacyService = new PharmacyService(_pharmacyBuilderMock.Object, _cacheRepositoryMock.Object, _loggerMock.Object); await Assert.ThrowsAsync <ArgumentNullException>(async() => await pharmacyService.FindClosestAsync(null)); }
public async Task FindClosestWhenCacheIsNotNull() { _pharmacyBuilderMock.Setup(x => x.FindClosestAsync(It.IsAny <PharmacyInputModel>())); _cacheRepositoryMock.Setup(x => x.GetByKeyAsync <PharmacyModel>(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(new PharmacyModel()); var pharmacyService = new PharmacyService(_pharmacyBuilderMock.Object, _cacheRepositoryMock.Object, _loggerMock.Object); await pharmacyService.FindClosestAsync(new PharmacyInputModel()); _pharmacyBuilderMock.Verify(x => x.FindClosestAsync(It.IsAny <PharmacyInputModel>()), Times.Never); }
private App() { EmailVerificationService = new EmailVerificationService(); SftpService = new SftpService(); HttpService = new HttpService(); TenderService = new TenderService(); MedicalExaminationService = new MedicalExaminationService( new MedicalExaminationRepository(new MySQLStream <MedicalExamination>(), new IntSequencer())); PatientFeedbackService = new PatientFeedbackService( new PatientFeedbackRepository(new MySQLStream <PatientFeedback>(), new IntSequencer())); MedicalExaminationReportService = new MedicalExaminationReportService( new MedicalExaminationReportRepository(new MySQLStream <MedicalExaminationReport>(), new IntSequencer())); PrescriptionService = new PrescriptionService( new PrescriptionRepository(new MySQLStream <Prescription>(), new IntSequencer())); MedicalRecordService = new MedicalRecordService( new MedicalRecordRepository(new MySQLStream <MedicalRecord>(), new IntSequencer()), EmailVerificationService); QuestionService = new QuestionService( new QuestionRepository(new MySQLStream <Question>(), new IntSequencer())); AnswerService = new AnswerService( new AnswerRepository(new MySQLStream <Answer>(), new IntSequencer()), QuestionService); AllergiesService = new AllergiesService( new AllergiesRepository(new MySQLStream <Allergies>(), new IntSequencer())); PatientService = new PatientService( new PatientRepository(new MySQLStream <Patient>(), new IntSequencer())); SurveyService = new SurveyService( new SurveyRepository(new MySQLStream <Survey>(), new IntSequencer()), MedicalExaminationService, AnswerService); DoctorService = new DoctorService( new DoctorRepository(new MySQLStream <Doctor>(), new IntSequencer())); ReportService = new ReportService( new ReportRepository(new MySQLStream <Report>(), new IntSequencer()), SftpService); DoctorWorkDayService = new DoctorWorkDayService( new DoctorWorkDayRepository(new MySQLStream <DoctorWorkDay>(), new IntSequencer()), DoctorService); SpetialitationService = new SpetialitationService( new SpecialitationRepository(new MySQLStream <Specialitation>(), new IntSequencer())); AppointmentService = new AppointmentService( new AppointmentRepository(new MySQLStream <Appointment>(), new IntSequencer()), PatientService); EPrescriptionService = new EPrescriptionService( new EPrescriptionRepository(new MySQLStream <EPrescription>(), new IntSequencer()), SftpService); PharmacyService = new PharmacyService( new PharmacyRepository(new MySQLStream <Pharmacies>(), new IntSequencer())); RoomService = new RoomService( new RoomRepository(new MySQLStream <Room>(), new IntSequencer())); ManagerService = new ManagerService( new ManagerRepository(new MySQLStream <Manager>(), new IntSequencer())); SecretaryService = new SecretaryService( new SecretaryRepository(new MySQLStream <Secretary>(), new IntSequencer())); SystemAdministratorService = new SystemAdministratorService( new SystemAdministratorRepository(new MySQLStream <SystemAdministrator>(), new IntSequencer())); UserService = new UserService( new UserRepository(new MySQLStream <User>(), new IntSequencer()), PatientService, SystemAdministratorService); }
public JsonResult GetAllPharmacies() { using (var service = new PharmacyService()) { List <PharmacyModel> result = new List <PharmacyModel>(); var test = service.GetAll(); //make a model to hold this foreach (var t in test) { result.Add(new PharmacyModel(t)); } return(Json(result)); } }
public async Task FindClosestWhenCacheIsNullAndBuilderReturnsNotNull() { _pharmacyBuilderMock.Setup(x => x.FindClosestAsync(It.IsAny <PharmacyInputModel>())).ReturnsAsync(new PharmacyModel()); _cacheRepositoryMock.Setup(x => x.GetByKeyAsync <PharmacyModel>(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(() => null); var pharmacyService = new PharmacyService(_pharmacyBuilderMock.Object, _cacheRepositoryMock.Object, _loggerMock.Object); await pharmacyService.FindClosestAsync(new PharmacyInputModel()); _pharmacyBuilderMock.Verify(x => x.FindClosestAsync(It.IsAny <PharmacyInputModel>()), Times.Once); _cacheRepositoryMock.Verify(x => x.UpsertKeyAsync(It.IsAny <string>(), It.IsAny <PharmacyModel>()), Times.Once); _cacheRepositoryMock.Verify(x => x.SetKeyExpirationAsync(It.IsAny <string>(), It.IsAny <TimeSpan>()), Times.Once); }
private async void Enter() { if (!String.IsNullOrWhiteSpace(Login) && !String.IsNullOrWhiteSpace(Password)) { User user = new User { login = Login, password = Password }; PharmacyService service = new PharmacyService(); await service.Login(user); } }
public JsonResult Inactivate(int PharmacyId) { using (var service = new PharmacyService()) { var result = service.Get(PharmacyId); using (var pservice = new JobService()) { foreach (var pharmacist in result.Jobs) { pharmacist.IsActive = false; pservice.Update(pharmacist); } } return(Json(true)); } }
public void setPharmacy(int code) { if (code < 0) { Pharmacy = new Pharmacy(-1, "System Admin", "000-000-0000", "no address"); Type = AccountTypes.System; } else { using (var service = new PharmacyService()) { Pharmacy = service.Get(code); Type = AccountTypes.Pharmacist; } } }
public ActionResult AddPharmacy(string Name, string Address, string Phone) { Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", ""); if (Phone.Length == 10) { Phone = "1" + Phone; } using (var service = new PharmacyService()) { int Code = service.GetAll().Max(x => x.Code); //this is an issue with the db where the code is auto set to 0 when creating a pharmacy Pharmacy p = new Pharmacy(++Code, Name, Phone, Address); service.Create(p); } return(RedirectToAction("PharmacyView", new RouteValueDictionary( new { controller = "SystemAdmin", action = "PharmacyView" }))); }
public ActionResult EditPharmacy(int PharmacyCode, string Name, string Address, string Phone) { Phone = Regex.Replace(Phone, @"[^A-Za-z0-9]+", ""); if (Phone.Length == 10) { Phone = "1" + Phone; } using (var service = new PharmacyService()) { Pharmacy p = service.Get(PharmacyCode); p.Name = Name; p.Address = Address; p.Phone = Phone; service.Update(p); } return(RedirectToAction("SinglePharmacy", new RouteValueDictionary( new { controller = "SystemAdmin", action = "SinglePharmacy", Id = PharmacyCode }))); }
public async void Search_ForDrug_Found_And_NotFound() { DbContextInMemory testData = new DbContextInMemory(); MyDbContext context = testData._context; var p = context.Pharmacies; IPharmacyService pharmacyService = new PharmacyService(new MySqlPharmacyRepo(context)); var pharmacyServiceMock = new Mock <IPharmacySystemService>(); pharmacyServiceMock.Setup(s => s.GetAll()).Returns(Task.Run(() => (pharmacyService.GetAllPharmacies()).ToList())); var adapterContext = new Mock <IAdapterContext>(); adapterContext.Setup(c => c.PharmacySystemAdapter.DrugAvailibility(It.Is <string>(name => name == "droga"))).Returns( new List <DrugDto>() { new DrugDto() { Id = 1, Name = "droga", Quantity = 5, PharmacyDto = new PharmacyDto { Id = 1, Name = "lokacija-1" } }, new DrugDto() { Id = 4, Name = "drogaricin", Quantity = 5, PharmacyDto = new PharmacyDto { Id = 3, Name = "lokacija-3" } } } ); adapterContext.Setup(c => c.PharmacySystemAdapter.DrugAvailibility(It.Is <string>(name => name != "droga"))).Returns(new List <DrugDto>()); adapterContext.Setup(c => c.SetPharmacySystemAdapter(It.IsAny <PharmacySystem>())).Returns(new Mock <IPharmacySystemAdapter>().Object); adapterContext.Setup(c => c.RemoveAdapter()).Verifiable(); DrugAvailabilityController controller = new DrugAvailabilityController(adapterContext.Object, pharmacyServiceMock.Object); ViewResult result = await controller.Search("droga") as ViewResult; adapterContext.Verify(c => c.RemoveAdapter()); Assert.NotEmpty((IEnumerable <SearchResultDto>)result.Model); result = await controller.Search("nesto") as ViewResult; adapterContext.Verify(c => c.RemoveAdapter()); Assert.Empty((IEnumerable <SearchResultDto>)result.Model); }
public async Task <Result <PatientStartTreatmentResponse> > Handle(PatientStartTreatmentCommand request, CancellationToken cancellationToken) { try { PharmacyService pharm = new PharmacyService(_unitOfWork); var result = await pharm.HasPatientTreatmentStarted(request.PatientId); return(Result <PatientStartTreatmentResponse> .Valid(new PatientStartTreatmentResponse { StartTreatment = result })); } catch (Exception ex) { return(Result <PatientStartTreatmentResponse> .Invalid(ex.Message)); } }
private async void SignUpButton_Clicked(object sender, EventArgs e) { PharmacyService Pharmacyservice = new PharmacyService(); var _pharmacyS = await Pharmacyservice.GetPharmacyByPhoneNoAsync(phoneNo.Text); GetCurrentXY(); if (x == 0 & y == 0) { return; } if (_pharmacyS.Count == 0) { KooshDaroo.Models.Pharmacy _pharmacy = new KooshDaroo.Models.Pharmacy { City = city.SelectedItem.ToString(), Title = pharmacy.Text, X = x, Y = y, PhoneNo = phoneNo.Text, is24h = is24h.IsChecked }; var result = Pharmacyservice.PostPharmacyAsync(_pharmacy); App.myId = result.Result.id; App.myPhoneNo = result.Result.PhoneNo; } else { App.myId = _pharmacyS[0].id; App.myPhoneNo = _pharmacyS[0].PhoneNo; } KooshDarooDatabase odb = new KooshDarooDatabase(); tblPharmacy newPharmacy = new tblPharmacy { City = city.SelectedItem.ToString(), Title = pharmacy.Text, X = x, Y = y, PhoneNo = phoneNo.Text, is24h = is24h.IsChecked }; int r = await odb.SavePharmacyAsync(newPharmacy); //odb = new KooshDarooDatabase(); //var oLoginItemS = odb.GetPharmacysAsync(); //var o = oLoginItemS.Result.Count; App.Current.MainPage = new NavigationPage(new MainPageTabbed()); //App.Current.MainPage = new MainPageTabbed(); //App.Current.MainPage = new PrescribesListPage(); //await this.Navigation.PushAsync(new PrescribesListPage()); }
public PharmacistModel(Pharmacist p, int PharmacyCode) { Code = p.Code; FirstName = p.FirstName; LastName = p.LastName; Email = p.Email; Phone = p.Phone; using (var service = new PharmacyService()) { var temp = service.Get(PharmacyCode); var temp1 = p.AllJobs.Where(x => x.Code == p.Code).FirstOrDefault(); if (temp1 != null) { isAdmin = temp1.IsAdmin; isActive = temp1.IsActive; } PharmacyName = temp.Name; PharmacyPhone = temp.Phone; PharmacyAddress = temp.Address; } this.PharmacyCode = PharmacyCode; }
private async void Enter() { if (!String.IsNullOrWhiteSpace(Login) && !String.IsNullOrWhiteSpace(Password)) { PharmacyService service = new PharmacyService(); var user1 = await service.Login(user); if (user1 == null) { Device.BeginInvokeOnMainThread(() => { App.NavigationPage.Navigation.PopToRootAsync(); }); } else { Device.BeginInvokeOnMainThread(() => { App.NavigationPage.Navigation.PushAsync(new WelcomePage()); }); } } }
public async void Registration() { if (IsNullOrWhiteSpaceExtension.AllIsNullOrWhiteSpace(false, FirstName, SecondName, Address, BornDate, Mail, Number)) { PharmacyService service = new PharmacyService(); var user = await service.Add(usr); if (user == null) { Device.BeginInvokeOnMainThread(() => { App.NavigationPage.Navigation.PopToRootAsync(); }); } else { Device.BeginInvokeOnMainThread(() => { App.NavigationPage.Navigation.PopToRootAsync(); App.NavigationPage.Navigation.PushAsync(new LoginPage()); }); } } }
public void PharmacyTest1() { //create an interface that will assert queries TestingDatabaseInterface inter = new TestingDatabaseInterface(); //tell the database to use our interface DatabaseService.RedirectDatabase(() => inter); int code = 1; string name = "TestPharmacy"; string address = "#### Street, City, State, Zip"; string phone = "123-456-7890"; inter.Expect( "Insert Into [Pharmacy]([Code],[Name],[Phone],[Address]) VALUES (@Code,@Name,@Phone,@Address)", new { Code = code, Name = name, Address = address, Phone = phone } ); foreach (var entry in PharmacyService.defaultMessageTemplates) { inter.Expect( "Insert Into [MessageTemplate]([PharmacyCode],[Type],[Media],[Content]) OUTPUT INSERTED.[Code] VALUES (@PharmacyCode,@Type,@Media,@Content)", new { PharmacyCode = code, Type = entry.Key.Type, Media = entry.Key.Media, Content = entry.Value }, new dynamic[] { new Dictionary <string, object>() { { "Code", 1 } } } ); } using (var service = new PharmacyService()) { Pharmacy pharm = new Pharmacy { Code = code, Name = name, Address = address, Phone = phone }; service.Create(pharm); } }
public LoginController(PharmacyContext context) { _context = context; _pharmacyService = new PharmacyService(); }
public void Constructor_when_give_correctly_repository() { IPharmacyService pharmacyService = new PharmacyService(pharmacyRepository); Assert.IsType <PharmacyService>(pharmacyService); }