Changeset a55ef91 for FarmatikoData


Ignore:
Timestamp:
07/31/20 10:15:02 (4 years ago)
Author:
DimitarSlezenkovski <dslezenkovski@…>
Branches:
master
Children:
d8fafb8
Parents:
4e72684
Message:

Update & add service

Location:
FarmatikoData
Files:
2 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoData/FarmatikoData.csproj

    r4e72684 ra55ef91  
    2323      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    2424    </PackageReference>
     25    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    2526    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
    2627  </ItemGroup>
  • FarmatikoData/FarmatikoRepo/HealthFacilityRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.FarmatikoRepoInterfaces;
    2 using System;
    32using System.Linq;
    4 using System.Collections.Generic;
    5 using System.Text;
    63using FarmatikoData.Models;
    7 using Microsoft.EntityFrameworkCore;
    84
    95namespace FarmatikoData.FarmatikoRepo
     
    2117        {
    2218            _context.Add(healthFacility);
    23             _context.SaveChangesAsync();
     19            _context.SaveChanges();
    2420        }
    2521
    26         public IEnumerable<HealthFacilities> GetAll()
     22        public IQueryable<HealthFacilities> GetAll()
    2723        {
    28             return _context.HealthFacilities.OrderBy(x => x.Name).ToList();
     24            return _context.HealthFacilities.OrderBy(x => x.Name);
    2925        }
    3026
     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        }
    3132    }
    3233}
  • FarmatikoData/FarmatikoRepo/HealthcareWorkerRepository.cs

    r4e72684 ra55ef91  
    22using FarmatikoData.Models;
    33using System.Linq;
    4 using System.Collections.Generic;
    54
    65namespace FarmatikoData.FarmatikoRepo
     
    1817        public void Add(HealthcareWorkers HealthcareWorker)
    1918        {
    20             _context.Add(HealthcareWorker);
     19            _context.HealthcareWorkers.Add(HealthcareWorker);
    2120            _context.SaveChangesAsync();
    2221        }
    2322
    24         public IEnumerable<HealthcareWorkers> GetAll()
     23        public IQueryable<HealthcareWorkers> GetAll()
    2524        {
    2625            return _context.HealthcareWorkers.OrderBy(x => x.Name);
     
    2928        public void Remove(HealthcareWorkers healthcareWorker)
    3029        {
    31             _context.Remove(healthcareWorker);
     30            var healthCareWorker = _context.HealthcareWorkers.Where(x => x.Name.Equals(healthcareWorker.Name));
     31            _context.HealthcareWorkers.Remove((HealthcareWorkers)healthCareWorker);
    3232        }
    3333    }
  • FarmatikoData/FarmatikoRepo/MedicineListRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.Models;
     2using Microsoft.EntityFrameworkCore;
    23using System.Collections.Generic;
    34using System.Linq;
     
    1718            _context.SaveChangesAsync();
    1819        }
    19         public MedicineList CheckMedicine(string Name)
     20        /*public MedicineList CheckMedicine(string Name)
    2021        {
    2122            return (MedicineList)_context.MedicineLists
    2223                .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()
    2730        {
    2831            return _context.MedicineLists.OrderBy(x => x.Medicine.Name);
     
    3336            return (ICollection<MedicineList>)_context.MedicineLists
    3437                .Where(x => x.Medicine.Manufacturer.Contains(Manufacturer))
    35                 .OrderBy(x => x.Medicine.Name);
     38                .OrderBy(x => x.Medicine.Name)
     39                .Cast<ICollection<MedicineList>>();
    3640        }
    3741        public ICollection<MedicineList> GetByName(string Name)
     
    3943            return (ICollection<MedicineList>)_context.MedicineLists
    4044                .Where(x => x.Medicine.Name.Contains(Name))
    41                 .OrderBy(x => x.Medicine.Name);
     45                .OrderBy(x => x.Medicine.Name)
     46                .Cast<ICollection<MedicineList>>();
    4247        }
    4348
    4449        public void Remove(MedicineList medicineList)
    4550        {
    46             var list = (MedicineList)_context.MedicineLists.Where(x => x.Equals(medicineList));
     51            var list = (MedicineList)_context.MedicineLists.Where(x => x.Medicine.Equals(medicineList.Medicine));
    4752            _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                 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             }
    7453        }
    7554    }
  • FarmatikoData/FarmatikoRepo/MedicineRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.FarmatikoRepoInterfaces;
    22using FarmatikoData.Models;
    3 using System.Collections.Generic;
     3using System;
    44using System.Linq;
    55
     
    1515        public void Add(Medicine Medicine)
    1616        {
    17             _context.Add(Medicine);
     17            _context.Medicines.Add(Medicine);
    1818            _context.SaveChangesAsync();
    1919        }
    2020
    21         public IEnumerable<Medicine> GetAll()
     21        public IQueryable<Medicine> GetAll()
    2222        {
    2323            return _context.Medicines.OrderBy(x => x.Name);
    2424        }
    2525
    26         public IEnumerable<Medicine> GetByManufacturer(string Manufacturer)
     26        public IQueryable<Medicine> GetByManufacturer(string Manufacturer)
    2727        {
    2828            return _context.Medicines.Where(x => x.Name.Contains(Manufacturer)).OrderBy(x => x.Manufacturer);
    2929        }
    3030
    31         public IEnumerable<Medicine> GetByName(string Name)
     31        public IQueryable<Medicine> GetByName(string Name)
    3232        {
    33             return _context.Medicines.Where(medicine => medicine.Name == Name);
     33            return _context.Medicines.Where(medicine => medicine.Name.Contains(Name)).OrderBy(x => x.Name);
    3434        }
    3535
  • FarmatikoData/FarmatikoRepo/PandemicRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.FarmatikoRepoInterfaces;
    22using FarmatikoData.Models;
    3 using Microsoft.EntityFrameworkCore;
    4 using System;
    5 using System.Collections.Generic;
    63using System.Linq;
    7 using System.Text;
    84
    95namespace FarmatikoData.FarmatikoRepo
     
    2420        }
    2521
    26         public IEnumerable<Pandemic> GetAll()
     22        public IQueryable<Pandemic> GetAll()
    2723        {
    28             return _context.Pandemics;
     24            return _context.Pandemics.OrderBy(x => x.Name);
    2925        }
    3026
  • FarmatikoData/FarmatikoRepo/PharmacyHeadRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.FarmatikoRepoInterfaces;
    22using FarmatikoData.Models;
    3 using System;
    4 using System.Collections.Generic;
    53using System.Linq;
    6 using System.Text;
    74
    85namespace FarmatikoData.FarmatikoRepo
     
    4542        public void Remove(PharmacyHead pharmacyHead, string Name)
    4643        {
    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();
    4845            _context.PharmacyHeads.Remove(phead);
    4946            _context.SaveChangesAsync();
  • FarmatikoData/FarmatikoRepo/PharmacyRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.FarmatikoRepoInterfaces;
    22using FarmatikoData.Models;
    3 using System;
    43using System.Collections.Generic;
    54using System.Linq;
    6 using System.Text;
    75
    86namespace FarmatikoData.FarmatikoRepo
     
    2321        }
    2422        //Just for users
    25         public IEnumerable<Pharmacy> GetAll()
     23        public IQueryable<Pharmacy> GetAll()
    2624        {
    2725            return _context.Pharmacies.OrderBy(x => x.Name);
     
    3634                pharmacy.Location,
    3735                pharmacy.WorkAllTime
    38             });
     36            }).OrderBy(x => x.Name);
    3937        }
    4038
    4139        public void Remove(Pharmacy pharmacy)
    4240        {
    43             var pharma = _context.Pharmacies.Where(pharm => pharm.Equals(pharmacy));
     41            var pharma = _context.Pharmacies.Where(pharm => pharm.Name.Equals(pharmacy.Name)).Cast<Pharmacy>();
    4442            _context.Pharmacies.Remove((Pharmacy)pharma);
    4543            _context.SaveChangesAsync();
     
    4846        public void UpdatePharmacy(Pharmacy pharmacy, string Name)
    4947        {
    50             var oldPharmacy = _context.Pharmacies.Where(pharma => pharma.Name.Equals(Name));
     48            var oldPharmacy = _context.Pharmacies.Where(pharma => pharma.Name.Equals(Name)).Cast<Pharmacy>();
    5149            _context.Pharmacies.Remove((Pharmacy)oldPharmacy);
    5250            _context.Pharmacies.Add(pharmacy);
  • FarmatikoData/FarmatikoRepoInterfaces/IHealthFacilityRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.Models;
    2 using System;
    3 using System.Collections.Generic;
    4 using System.Text;
     2using System.Linq;
    53
    64namespace FarmatikoData.FarmatikoRepoInterfaces
     
    86    public interface IHealthFacilityRepository
    97    {
    10         IEnumerable<HealthFacilities> GetAll();
     8        IQueryable<HealthFacilities> GetAll();
    119        void Add(HealthFacilities healthFacility);
     10        void Remove(HealthFacilities healthFacility);
    1211    }
    1312}
  • FarmatikoData/FarmatikoRepoInterfaces/IHealthcareWorkerRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.Models;
    2 using System;
    3 using System.Collections.Generic;
    4 using System.Text;
     2using System.Linq;
    53
    64namespace FarmatikoData.FarmatikoRepoInterfaces
     
    86    public interface IHealthcareWorkerRepository
    97    {
    10         IEnumerable<HealthcareWorkers> GetAll();
     8        IQueryable<HealthcareWorkers> GetAll();
    119        void Add(HealthcareWorkers HealthcareWorker);
    1210        void Remove(HealthcareWorkers healthcareWorker);
  • FarmatikoData/FarmatikoRepoInterfaces/IMedicineListRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.Models;
    22using System.Collections.Generic;
     3using System.Linq;
    34
    45namespace FarmatikoData.FarmatikoRepo
     
    89        void Add(MedicineList medicineList);
    910        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);
    1414        ICollection<MedicineList> GetByName(string Name);
    1515        ICollection<MedicineList> GetByManufacturer(string Manufacturer);
    16         bool SetHasMedicine(MedicineList medicineList, bool HasMedicine);
     16        //bool SetHasMedicine(MedicineList medicineList, bool HasMedicine);
     17        //void SetHasMedicine(MedicineList medicineList);       
    1718    }
    1819}
  • FarmatikoData/FarmatikoRepoInterfaces/IMedicineRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.Models;
    2 using System;
    3 using System.Collections.Generic;
    4 using System.Text;
     2using System.Linq;
    53
    64namespace FarmatikoData.FarmatikoRepoInterfaces
     
    86    public interface IMedicineRepository
    97    {
    10         IEnumerable<Medicine> GetAll();
    11         IEnumerable<Medicine> GetByName(string Name);
     8        IQueryable<Medicine> GetAll();
     9        IQueryable<Medicine> GetByName(string Name);
    1210        void Add(Medicine medicine);
    1311        void Remove(string medicine);
    14         IEnumerable<Medicine> GetByManufacturer(string Manufacturer);
     12        IQueryable<Medicine> GetByManufacturer(string Manufacturer);
    1513
    1614    }
  • FarmatikoData/FarmatikoRepoInterfaces/IPandemicRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.Models;
    2 using System;
    3 using System.Collections.Generic;
    4 using System.Text;
     2using System.Linq;
    53
    64namespace FarmatikoData.FarmatikoRepoInterfaces
     
    86    public interface IPandemicRepository
    97    {
    10         IEnumerable<Pandemic> GetAll();
     8        IQueryable<Pandemic> GetAll();
    119        void Add(Pandemic pandemic);
    1210        void Remove(Pandemic pandemic);
  • FarmatikoData/FarmatikoRepoInterfaces/IPharmacyHeadRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.Models;
    2 using System;
    3 using System.Collections.Generic;
    42using System.Linq;
    5 using System.Text;
    63
    74namespace FarmatikoData.FarmatikoRepoInterfaces
  • FarmatikoData/FarmatikoRepoInterfaces/IPharmacyRepository.cs

    r4e72684 ra55ef91  
    11using FarmatikoData.Models;
    2 using System;
    32using System.Collections.Generic;
    4 using System.Text;
     3using System.Linq;
    54
    65namespace FarmatikoData.FarmatikoRepoInterfaces
     
    109        void Add(Pharmacy pharmacy);
    1110        ICollection<Pharmacy> GetPharmacies();
    12         IEnumerable<Pharmacy> GetAll();
     11        IQueryable<Pharmacy> GetAll();
    1312        void Remove(Pharmacy pharmacy);
    1413        void UpdatePharmacy(Pharmacy pharmacy, string Name);
  • FarmatikoData/Models/HealthFacilities.cs

    r4e72684 ra55ef91  
    11using System;
     2using System.Collections;
    23using System.Collections.Generic;
    34using System.ComponentModel.DataAnnotations;
Note: See TracChangeset for help on using the changeset viewer.