Changeset 4e72684
- Timestamp:
- 07/29/20 20:02:58 (4 years ago)
- Branches:
- master
- Children:
- a55ef91
- Parents:
- de18858
- Files:
-
- 10 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Farmatiko/Startup.cs
rde18858 r4e72684 1 1 using Microsoft.AspNetCore.Builder; 2 2 using Microsoft.AspNetCore.Hosting; 3 using Microsoft.AspNetCore.HttpsPolicy;4 3 using Microsoft.AspNetCore.SpaServices.AngularCli; 5 4 using Microsoft.Extensions.Configuration; … … 50 49 services.AddTransient<IHealthFacilityRepository, HealthFacilityRepository>(); 51 50 services.AddTransient<IHealthFacilityService, HealthFacilityService>(); 51 52 52 services.AddTransient<IHealthcareWorkerRepository, HealthcareWorkerRepository>(); 53 53 services.AddTransient<IHealthcareWorkerService, HealthcareWorkerService>(); 54 55 services.AddTransient<IMedicineRepository, MedicineRepository>(); 56 services.AddTransient<IMedicineService, MedicineService>(); 57 58 services.AddTransient<IMedicineListRepository, MedicineListRepository>(); 59 services.AddTransient<IMedicineListService, MedicineListService>(); 60 61 services.AddTransient<IPandemicRepository, PandemicRepository>(); 62 services.AddTransient<IPandemicService, PandemicService>(); 63 64 services.AddTransient<IPharmacyHeadRepository, PharmacyHeadRepository>(); 65 services.AddTransient<IPharmacyHeadService, PharmacyHeadService>(); 66 67 services.AddTransient<IPharmacyRepository, PharmacyRepository>(); 68 services.AddTransient<IPharmacyService, PharmacyService>(); 54 69 } 55 70 -
FarmatikoData/FarmatikoRepo/MedicineListRepository.cs
rde18858 r4e72684 1 1 using FarmatikoData.Models; 2 using Microsoft.EntityFrameworkCore;3 using System;4 2 using System.Collections.Generic; 5 3 using System.Linq; 6 using System.Text;7 4 8 5 namespace FarmatikoData.FarmatikoRepo … … 20 17 _context.SaveChangesAsync(); 21 18 } 22 // Maybe later 23 /*public MedicineList CheckMedicine(string Name) 19 public MedicineList CheckMedicine(string Name) 24 20 { 25 21 return (MedicineList)_context.MedicineLists 26 22 .Where(medicineList => medicineList.Medicine.Name.Contains(Name)) 27 23 .OrderBy(x => x.Medicine.Name); 28 } */24 } 29 25 30 public I Collection<MedicineList> GetAll()26 public IEnumerable<MedicineList> GetAll() 31 27 { 32 return (ICollection<MedicineList>)_context.MedicineLists.OrderBy(x => x.Medicine.Name);28 return _context.MedicineLists.OrderBy(x => x.Medicine.Name); 33 29 } 34 30 … … 49 45 { 50 46 var list = (MedicineList)_context.MedicineLists.Where(x => x.Equals(medicineList)); 51 _context. Remove(list);47 _context.MedicineLists.Remove(list); 52 48 } 53 49 54 public voidSetHasMedicine(MedicineList medicineList, bool HasMedicine)50 public bool SetHasMedicine(MedicineList medicineList, bool HasMedicine) 55 51 { 56 var medicine = _context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine)); 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 else 64 { 65 medicine.HasMedicine = HasMedicine; 66 _context.MedicineLists.Add(medicine); 67 _context.SaveChangesAsync(); 68 return true; 69 } 70 }else 71 { 72 return false; 73 } 57 74 } 58 75 } -
FarmatikoData/FarmatikoRepo/MedicineRepository.cs
rde18858 r4e72684 1 1 using FarmatikoData.FarmatikoRepoInterfaces; 2 2 using FarmatikoData.Models; 3 using Microsoft.EntityFrameworkCore;4 using System;5 3 using System.Collections.Generic; 6 4 using System.Linq; 7 using System.Text;8 5 9 6 namespace FarmatikoData.FarmatikoRepo … … 24 21 public IEnumerable<Medicine> GetAll() 25 22 { 26 return _context.Medicines. Include(medicine => medicine.Name).Include(medicine => medicine.Strength).Include(medicine => medicine.Form);23 return _context.Medicines.OrderBy(x => x.Name); 27 24 } 28 25 … … 34 31 public IEnumerable<Medicine> GetByName(string Name) 35 32 { 36 return (IEnumerable<Medicine>)_context.Medicines.Where(medicine => medicine.Name == Name);33 return _context.Medicines.Where(medicine => medicine.Name == Name); 37 34 } 38 35 … … 40 37 { 41 38 Medicine med = (Medicine)_context.Medicines.Where(medicine => medicine.Name.Equals(medicine)); 42 _context. Remove(med);39 _context.Medicines.Remove(med); 43 40 } 44 41 } -
FarmatikoData/FarmatikoRepo/PharmacyHeadRepository.cs
rde18858 r4e72684 23 23 } 24 24 25 public I Collection<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead)25 public IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHeads) 26 26 { 27 return (ICollection<PharmacyHead>)_context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Equals(NameOfPharmacyHead)); 27 return _context.PharmacyHeads 28 .Where(pharmacyHead => pharmacyHead.Name.Contains(NameOfPharmacyHeads)) 29 .OrderBy(x => x.Name); 28 30 } 29 31 //Not needed 30 public I Enumerable<PharmacyHead> GetPharmacyByName(string Name)32 public IQueryable<PharmacyHead> GetPharmacyByName(string Name) 31 33 { 32 34 return _context.PharmacyHeads.Where(pharmacyHead => pharmacyHead.Name.Equals(Name)); 35 } 36 37 public IQueryable<MedicineList> GetPharmacyMedicines(string NameOfPharmacy) 38 { 39 40 IQueryable<MedicineList> Pharmacy = (IQueryable<MedicineList>)_context.PharmacyHeads.Where(x => x.Name.Equals(NameOfPharmacy)); 41 42 return Pharmacy; 33 43 } 34 44 -
FarmatikoData/FarmatikoRepo/PharmacyRepository.cs
rde18858 r4e72684 21 21 _context.Pharmacies.Add(pharmacy); 22 22 _context.SaveChangesAsync(); 23 } 24 //Just for users 25 public IEnumerable<Pharmacy> GetAll() 26 { 27 return _context.Pharmacies.OrderBy(x => x.Name); 23 28 } 24 29 -
FarmatikoData/FarmatikoRepoInterfaces/IMedicineListRepository.cs
rde18858 r4e72684 1 1 using FarmatikoData.Models; 2 using System;3 2 using System.Collections.Generic; 4 using System.Text;5 3 6 4 namespace FarmatikoData.FarmatikoRepo … … 10 8 void Add(MedicineList medicineList); 11 9 void Remove(MedicineList medicineList); 12 I Collection<MedicineList> GetAll();10 IEnumerable<MedicineList> GetAll(); 13 11 //Not needed, maybe later 14 12 /*MedicineList CheckMedicine(MedicineList medicineList, bool HasMedicine); … … 16 14 ICollection<MedicineList> GetByName(string Name); 17 15 ICollection<MedicineList> GetByManufacturer(string Manufacturer); 18 voidSetHasMedicine(MedicineList medicineList, bool HasMedicine);16 bool SetHasMedicine(MedicineList medicineList, bool HasMedicine); 19 17 } 20 18 } -
FarmatikoData/FarmatikoRepoInterfaces/IPharmacyHeadRepository.cs
rde18858 r4e72684 2 2 using System; 3 3 using System.Collections.Generic; 4 using System.Linq; 4 5 using System.Text; 5 6 … … 10 11 void Add(PharmacyHead pharmacyHead); 11 12 void Remove(PharmacyHead pharmacyHead, string Name); 12 I Collection<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead);13 IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead); 13 14 //Not actually needed 14 IEnumerable<PharmacyHead> GetPharmacyByName(string Name); 15 IQueryable<PharmacyHead> GetPharmacyByName(string Name); 16 IQueryable<MedicineList> GetPharmacyMedicines(string NameOfPharmacy); 15 17 } 16 18 } -
FarmatikoData/FarmatikoRepoInterfaces/IPharmacyRepository.cs
rde18858 r4e72684 10 10 void Add(Pharmacy pharmacy); 11 11 ICollection<Pharmacy> GetPharmacies(); 12 IEnumerable<Pharmacy> GetAll(); 12 13 void Remove(Pharmacy pharmacy); 13 14 void UpdatePharmacy(Pharmacy pharmacy, string Name); -
FarmatikoData/Models/Pandemic.cs
rde18858 r4e72684 10 10 { 11 11 public Pandemic() { } 12 public string Name { get; set; } 13 public int TotalMK { get; set; } 14 public int ActiveMK { get; set; } 15 public int DeathsMK { get; set; } 16 public int NewMK { get; set; } 17 public long TotalGlobal { get; set; } 18 public long DeathsGlobal { get; set; } 19 public long ActiveGlobal { get; set; } 12 20 public Pandemic(string Name, int TotalMK, int ActiveMK, 13 21 int DeathsMK, int NewMK, long TotalGlobal, long DeathsGlobal, long ActiveGlobal) … … 22 30 this.ActiveGlobal = ActiveGlobal; 23 31 } 24 public string Name { get; set; }25 public int TotalMK { get; set; }26 public int ActiveMK { get; set; }27 public int DeathsMK { get; set; }28 public int NewMK { get; set; }29 public long TotalGlobal { get; set; }30 public long DeathsGlobal { get; set; }31 public long ActiveGlobal { get; set; }32 32 } 33 33 } -
FarmatikoServices/FarmatikoServiceInterfaces/IMedicineListService.cs
rde18858 r4e72684 1 1 using FarmatikoData.Models; 2 using System;3 2 using System.Collections.Generic; 4 using System.Text;5 3 6 4 namespace FarmatikoServices.FarmatikoServiceInterfaces … … 8 6 public interface IMedicineListService 9 7 { 10 I Collection<MedicineList> GetAll();11 voidSetHasMedicine(MedicineList medicineList, bool HasMedicine);8 IEnumerable<MedicineList> GetAll(); 9 bool SetHasMedicine(MedicineList medicineList, bool HasMedicine); 12 10 ICollection<MedicineList> GetByName(string Name); 13 11 ICollection<MedicineList> GetByManufacturer(string Manufacturer); -
FarmatikoServices/Services/MedicineListService.cs
rde18858 r4e72684 2 2 using FarmatikoData.Models; 3 3 using FarmatikoServices.FarmatikoServiceInterfaces; 4 using System;5 4 using System.Collections.Generic; 6 using System.Text;7 5 8 6 namespace FarmatikoServices.Services … … 16 14 } 17 15 18 public I Collection<MedicineList> GetAll()16 public IEnumerable<MedicineList> GetAll() 19 17 { 20 18 return _medicineListRepository.GetAll(); … … 28 26 public ICollection<MedicineList> GetByName(string Name) 29 27 { 30 return _medicineListRepository.GetByName(Name); 28 if(Name != null) 29 { 30 return _medicineListRepository.GetByName(Name); 31 } 32 return null; 31 33 } 32 34 33 public voidSetHasMedicine(MedicineList medicineList, bool HasMedicine)35 public bool SetHasMedicine(MedicineList medicineList, bool HasMedicine) 34 36 { 35 throw new NotImplementedException(); 37 if (medicineList != null) 38 { 39 _medicineListRepository.SetHasMedicine(medicineList, HasMedicine); 40 return true; 41 } 42 else return false; 36 43 } 37 44 }
Note:
See TracChangeset
for help on using the changeset viewer.