Changeset a55ef91 for FarmatikoData
- Timestamp:
- 07/31/20 10:15:02 (4 years ago)
- Branches:
- master
- Children:
- d8fafb8
- Parents:
- 4e72684
- Location:
- FarmatikoData
- Files:
-
- 2 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoData/FarmatikoData.csproj
r4e72684 ra55ef91 23 23 <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> 24 24 </PackageReference> 25 <PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> 25 26 <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" /> 26 27 </ItemGroup> -
FarmatikoData/FarmatikoRepo/HealthFacilityRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 using System;3 2 using System.Linq; 4 using System.Collections.Generic;5 using System.Text;6 3 using FarmatikoData.Models; 7 using Microsoft.EntityFrameworkCore;8 4 9 5 namespace FarmatikoData.FarmatikoRepo … … 21 17 { 22 18 _context.Add(healthFacility); 23 _context.SaveChanges Async();19 _context.SaveChanges(); 24 20 } 25 21 26 public I Enumerable<HealthFacilities> GetAll()22 public IQueryable<HealthFacilities> GetAll() 27 23 { 28 return _context.HealthFacilities.OrderBy(x => x.Name) .ToList();24 return _context.HealthFacilities.OrderBy(x => x.Name); 29 25 } 30 26 27 public void Remove(HealthFacilities healthFacility) 28 { 29 var facility = _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility.Name)); 30 _context.HealthFacilities.Remove((HealthFacilities)facility); 31 } 31 32 } 32 33 } -
FarmatikoData/FarmatikoRepo/HealthcareWorkerRepository.cs
r4e72684 ra55ef91 2 2 using FarmatikoData.Models; 3 3 using System.Linq; 4 using System.Collections.Generic;5 4 6 5 namespace FarmatikoData.FarmatikoRepo … … 18 17 public void Add(HealthcareWorkers HealthcareWorker) 19 18 { 20 _context. Add(HealthcareWorker);19 _context.HealthcareWorkers.Add(HealthcareWorker); 21 20 _context.SaveChangesAsync(); 22 21 } 23 22 24 public I Enumerable<HealthcareWorkers> GetAll()23 public IQueryable<HealthcareWorkers> GetAll() 25 24 { 26 25 return _context.HealthcareWorkers.OrderBy(x => x.Name); … … 29 28 public void Remove(HealthcareWorkers healthcareWorker) 30 29 { 31 _context.Remove(healthcareWorker); 30 var healthCareWorker = _context.HealthcareWorkers.Where(x => x.Name.Equals(healthcareWorker.Name)); 31 _context.HealthcareWorkers.Remove((HealthcareWorkers)healthCareWorker); 32 32 } 33 33 } -
FarmatikoData/FarmatikoRepo/MedicineListRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 using Microsoft.EntityFrameworkCore; 2 3 using System.Collections.Generic; 3 4 using System.Linq; … … 17 18 _context.SaveChangesAsync(); 18 19 } 19 public MedicineList CheckMedicine(string Name)20 /*public MedicineList CheckMedicine(string Name) 20 21 { 21 22 return (MedicineList)_context.MedicineLists 22 23 .Where(medicineList => medicineList.Medicine.Name.Contains(Name)) 23 .OrderBy(x => x.Medicine.Name); 24 } 25 26 public IEnumerable<MedicineList> GetAll() 24 .OrderBy(x => x.Medicine.Name) 25 .Include(x => x.HasMedicine) 26 .Cast<MedicineList>(); 27 }*/ 28 29 public IQueryable<MedicineList> GetAll() 27 30 { 28 31 return _context.MedicineLists.OrderBy(x => x.Medicine.Name); … … 33 36 return (ICollection<MedicineList>)_context.MedicineLists 34 37 .Where(x => x.Medicine.Manufacturer.Contains(Manufacturer)) 35 .OrderBy(x => x.Medicine.Name); 38 .OrderBy(x => x.Medicine.Name) 39 .Cast<ICollection<MedicineList>>(); 36 40 } 37 41 public ICollection<MedicineList> GetByName(string Name) … … 39 43 return (ICollection<MedicineList>)_context.MedicineLists 40 44 .Where(x => x.Medicine.Name.Contains(Name)) 41 .OrderBy(x => x.Medicine.Name); 45 .OrderBy(x => x.Medicine.Name) 46 .Cast<ICollection<MedicineList>>(); 42 47 } 43 48 44 49 public void Remove(MedicineList medicineList) 45 50 { 46 var list = (MedicineList)_context.MedicineLists.Where(x => x. Equals(medicineList));51 var list = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine)); 47 52 _context.MedicineLists.Remove(list); 48 }49 50 public bool SetHasMedicine(MedicineList medicineList, bool HasMedicine)51 {52 MedicineList medicine = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Name.Equals(medicineList.Medicine.Name));53 54 if (medicine != null || medicineList != null)55 {56 if (HasMedicine == true)57 {58 medicine.HasMedicine = HasMedicine;59 _context.MedicineLists.Add(medicine);60 _context.SaveChangesAsync();61 return true;62 }63 else64 {65 medicine.HasMedicine = HasMedicine;66 _context.MedicineLists.Add(medicine);67 _context.SaveChangesAsync();68 return true;69 }70 }else71 {72 return false;73 }74 53 } 75 54 } -
FarmatikoData/FarmatikoRepo/MedicineRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using System .Collections.Generic;3 using System; 4 4 using System.Linq; 5 5 … … 15 15 public void Add(Medicine Medicine) 16 16 { 17 _context. Add(Medicine);17 _context.Medicines.Add(Medicine); 18 18 _context.SaveChangesAsync(); 19 19 } 20 20 21 public I Enumerable<Medicine> GetAll()21 public IQueryable<Medicine> GetAll() 22 22 { 23 23 return _context.Medicines.OrderBy(x => x.Name); 24 24 } 25 25 26 public I Enumerable<Medicine> GetByManufacturer(string Manufacturer)26 public IQueryable<Medicine> GetByManufacturer(string Manufacturer) 27 27 { 28 28 return _context.Medicines.Where(x => x.Name.Contains(Manufacturer)).OrderBy(x => x.Manufacturer); 29 29 } 30 30 31 public I Enumerable<Medicine> GetByName(string Name)31 public IQueryable<Medicine> GetByName(string Name) 32 32 { 33 return _context.Medicines.Where(medicine => medicine.Name ==Name);33 return _context.Medicines.Where(medicine => medicine.Name.Contains(Name)).OrderBy(x => x.Name); 34 34 } 35 35 -
FarmatikoData/FarmatikoRepo/PandemicRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using Microsoft.EntityFrameworkCore;4 using System;5 using System.Collections.Generic;6 3 using System.Linq; 7 using System.Text;8 4 9 5 namespace FarmatikoData.FarmatikoRepo … … 24 20 } 25 21 26 public I Enumerable<Pandemic> GetAll()22 public IQueryable<Pandemic> GetAll() 27 23 { 28 return _context.Pandemics ;24 return _context.Pandemics.OrderBy(x => x.Name); 29 25 } 30 26 -
FarmatikoData/FarmatikoRepo/PharmacyHeadRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using System;4 using System.Collections.Generic;5 3 using System.Linq; 6 using System.Text;7 4 8 5 namespace FarmatikoData.FarmatikoRepo … … 45 42 public void Remove(PharmacyHead pharmacyHead, string Name) 46 43 { 47 var phead = (PharmacyHead)_context.PharmacyHeads.Where(phead => phead.Name.Equals(Name)) ;44 var phead = (PharmacyHead)_context.PharmacyHeads.Where(phead => phead.Name.Equals(Name)).FirstOrDefault(); 48 45 _context.PharmacyHeads.Remove(phead); 49 46 _context.SaveChangesAsync(); -
FarmatikoData/FarmatikoRepo/PharmacyRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using System;4 3 using System.Collections.Generic; 5 4 using System.Linq; 6 using System.Text;7 5 8 6 namespace FarmatikoData.FarmatikoRepo … … 23 21 } 24 22 //Just for users 25 public I Enumerable<Pharmacy> GetAll()23 public IQueryable<Pharmacy> GetAll() 26 24 { 27 25 return _context.Pharmacies.OrderBy(x => x.Name); … … 36 34 pharmacy.Location, 37 35 pharmacy.WorkAllTime 38 }) ;36 }).OrderBy(x => x.Name); 39 37 } 40 38 41 39 public void Remove(Pharmacy pharmacy) 42 40 { 43 var pharma = _context.Pharmacies.Where(pharm => pharm. Equals(pharmacy));41 var pharma = _context.Pharmacies.Where(pharm => pharm.Name.Equals(pharmacy.Name)).Cast<Pharmacy>(); 44 42 _context.Pharmacies.Remove((Pharmacy)pharma); 45 43 _context.SaveChangesAsync(); … … 48 46 public void UpdatePharmacy(Pharmacy pharmacy, string Name) 49 47 { 50 var oldPharmacy = _context.Pharmacies.Where(pharma => pharma.Name.Equals(Name)) ;48 var oldPharmacy = _context.Pharmacies.Where(pharma => pharma.Name.Equals(Name)).Cast<Pharmacy>(); 51 49 _context.Pharmacies.Remove((Pharmacy)oldPharmacy); 52 50 _context.Pharmacies.Add(pharmacy); -
FarmatikoData/FarmatikoRepoInterfaces/IHealthFacilityRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 using System; 3 using System.Collections.Generic; 4 using System.Text; 2 using System.Linq; 5 3 6 4 namespace FarmatikoData.FarmatikoRepoInterfaces … … 8 6 public interface IHealthFacilityRepository 9 7 { 10 I Enumerable<HealthFacilities> GetAll();8 IQueryable<HealthFacilities> GetAll(); 11 9 void Add(HealthFacilities healthFacility); 10 void Remove(HealthFacilities healthFacility); 12 11 } 13 12 } -
FarmatikoData/FarmatikoRepoInterfaces/IHealthcareWorkerRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 using System; 3 using System.Collections.Generic; 4 using System.Text; 2 using System.Linq; 5 3 6 4 namespace FarmatikoData.FarmatikoRepoInterfaces … … 8 6 public interface IHealthcareWorkerRepository 9 7 { 10 I Enumerable<HealthcareWorkers> GetAll();8 IQueryable<HealthcareWorkers> GetAll(); 11 9 void Add(HealthcareWorkers HealthcareWorker); 12 10 void Remove(HealthcareWorkers healthcareWorker); -
FarmatikoData/FarmatikoRepoInterfaces/IMedicineListRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 2 using System.Collections.Generic; 3 using System.Linq; 3 4 4 5 namespace FarmatikoData.FarmatikoRepo … … 8 9 void Add(MedicineList medicineList); 9 10 void Remove(MedicineList medicineList); 10 IEnumerable<MedicineList> GetAll(); 11 //Not needed, maybe later 12 /*MedicineList CheckMedicine(MedicineList medicineList, bool HasMedicine); 13 public MedicineList CheckMedicine(string Name);*/ 11 IQueryable<MedicineList> GetAll(); 12 /*MedicineList CheckMedicine(MedicineList medicineList, bool HasMedicine);*/ 13 //public MedicineList CheckMedicine(string Name); 14 14 ICollection<MedicineList> GetByName(string Name); 15 15 ICollection<MedicineList> GetByManufacturer(string Manufacturer); 16 bool SetHasMedicine(MedicineList medicineList, bool HasMedicine); 16 //bool SetHasMedicine(MedicineList medicineList, bool HasMedicine); 17 //void SetHasMedicine(MedicineList medicineList); 17 18 } 18 19 } -
FarmatikoData/FarmatikoRepoInterfaces/IMedicineRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 using System; 3 using System.Collections.Generic; 4 using System.Text; 2 using System.Linq; 5 3 6 4 namespace FarmatikoData.FarmatikoRepoInterfaces … … 8 6 public interface IMedicineRepository 9 7 { 10 I Enumerable<Medicine> GetAll();11 I Enumerable<Medicine> GetByName(string Name);8 IQueryable<Medicine> GetAll(); 9 IQueryable<Medicine> GetByName(string Name); 12 10 void Add(Medicine medicine); 13 11 void Remove(string medicine); 14 I Enumerable<Medicine> GetByManufacturer(string Manufacturer);12 IQueryable<Medicine> GetByManufacturer(string Manufacturer); 15 13 16 14 } -
FarmatikoData/FarmatikoRepoInterfaces/IPandemicRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 using System; 3 using System.Collections.Generic; 4 using System.Text; 2 using System.Linq; 5 3 6 4 namespace FarmatikoData.FarmatikoRepoInterfaces … … 8 6 public interface IPandemicRepository 9 7 { 10 I Enumerable<Pandemic> GetAll();8 IQueryable<Pandemic> GetAll(); 11 9 void Add(Pandemic pandemic); 12 10 void Remove(Pandemic pandemic); -
FarmatikoData/FarmatikoRepoInterfaces/IPharmacyHeadRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 using System;3 using System.Collections.Generic;4 2 using System.Linq; 5 using System.Text;6 3 7 4 namespace FarmatikoData.FarmatikoRepoInterfaces -
FarmatikoData/FarmatikoRepoInterfaces/IPharmacyRepository.cs
r4e72684 ra55ef91 1 1 using FarmatikoData.Models; 2 using System;3 2 using System.Collections.Generic; 4 using System. Text;3 using System.Linq; 5 4 6 5 namespace FarmatikoData.FarmatikoRepoInterfaces … … 10 9 void Add(Pharmacy pharmacy); 11 10 ICollection<Pharmacy> GetPharmacies(); 12 I Enumerable<Pharmacy> GetAll();11 IQueryable<Pharmacy> GetAll(); 13 12 void Remove(Pharmacy pharmacy); 14 13 void UpdatePharmacy(Pharmacy pharmacy, string Name); -
FarmatikoData/Models/HealthFacilities.cs
r4e72684 ra55ef91 1 1 using System; 2 using System.Collections; 2 3 using System.Collections.Generic; 3 4 using System.ComponentModel.DataAnnotations;
Note:
See TracChangeset
for help on using the changeset viewer.