Changeset 1454207 for FarmatikoData


Ignore:
Timestamp:
10/01/20 03:17:09 (4 years ago)
Author:
DimitarSlezenkovski <dslezenkovski@…>
Branches:
master
Children:
6f203af
Parents:
5d02859
Message:

Change structure, Add repo, services & controllers

Location:
FarmatikoData
Files:
5 added
14 deleted
4 edited
2 moved

Legend:

Unmodified
Added
Removed
  • FarmatikoData/FarmatikoDataContext.cs

    r5d02859 r1454207  
    99       
    1010
    11         public virtual DbSet<HealthFacilities> HealthFacilities { get; set; }
    12         public virtual DbSet<HealthcareWorkers> HealthcareWorkers { get; set; }
     11        public virtual DbSet<HealthFacility> HealthFacilities { get; set; }
     12        public virtual DbSet<HealthcareWorker> HealthcareWorkers { get; set; }
    1313        public virtual DbSet<Pharmacy> Pharmacies { get; set; }
    1414        public virtual DbSet<PharmacyHead> PharmacyHeads { get; set; }
     
    1616        public virtual DbSet<Medicine> Medicines { get; set; }
    1717        public virtual DbSet<MedicineList> MedicineLists { get; set; }
    18 
     18        public virtual DbSet<RequestPharmacyHead> PHRequests { get; set; }
    1919    }
    2020}
  • FarmatikoData/FarmatikoRepo/Repository.cs

    r5d02859 r1454207  
    1414        }
    1515        //GET
    16         public async Task<IQueryable<HealthcareWorkers>> GetAllWorkers()
     16        public async Task<IQueryable<HealthcareWorker>> GetAllWorkers()
    1717        {
    1818            var Workers = await Task.Run(() => _context.HealthcareWorkers.Take(10));
     
    2020        }
    2121
    22         public async Task<IQueryable<HealthFacilities>> GetFacilities()
     22        public async Task<IQueryable<HealthFacility>> GetFacilities()
    2323        {
    2424            var Facilities = await Task.Run(() => _context.HealthFacilities.Take(10));
     
    2626        }
    2727
    28         public async Task<HealthFacilities> GetFacility(int Id)
     28        public async Task<HealthFacility> GetFacility(int Id)
    2929        {
    3030            var Facility = await _context.HealthFacilities.FindAsync(Id);
     
    6262        }
    6363
    64         public async Task<HealthcareWorkers> GetWorker(int id)
     64        public async Task<HealthcareWorker> GetWorker(int id)
    6565        {
    6666            var Worker = await _context.HealthcareWorkers.FindAsync(id);
     
    6868        }
    6969
    70         public async Task<IQueryable<HealthFacilities>> SearchFacilities(string query)
     70        public async Task<IQueryable<HealthFacility>> SearchFacilities(string query)
    7171        {
    7272            var SearchQuery = await Task.Run(() => _context.HealthFacilities
     
    9595        }
    9696
    97         public async Task<IQueryable<HealthcareWorkers>> SearchWorkers(string query)
     97        public async Task<IQueryable<HealthcareWorker>> SearchWorkers(string query)
    9898        {
    9999            var SearchQuery = await Task.Run(() => _context.HealthcareWorkers
     
    103103            return SearchQuery;
    104104        }
     105        public async Task<HealthFacility> GetFacilityJSON(string healthFacility)
     106        {
     107            var Facility = await Task.Run(() => _context.HealthFacilities.Where(x => x.Name.Equals(healthFacility)).FirstOrDefault());
     108            return Facility;
     109        }
    105110
    106111        //POST
    107112
    108         public async Task AddWorker(HealthcareWorkers Worker)
     113        public async Task AddWorker(HealthcareWorker Worker)
    109114        {
    110115            await Task.Run(() => _context.HealthcareWorkers.Add(Worker));
     
    112117        }
    113118
    114         public async Task AddFacility(HealthFacilities healthFacility)
     119        public async Task AddFacility(HealthFacility healthFacility)
    115120        {
    116121            await Task.Run(() => _context.HealthFacilities.Add(healthFacility));
     
    141146            await _context.SaveChangesAsync();
    142147        }
     148
     149        public async Task UpdateFacility(HealthFacility healthFacility)
     150        {
     151            var Facility = await Task.Run(() => _context.HealthFacilities.Where(x => x.Id == healthFacility.Id).FirstOrDefault());
     152            Facility.Address = healthFacility.Address;
     153            Facility.Email = healthFacility.Email;
     154            Facility.Municipality = healthFacility.Municipality;
     155            Facility.Name = healthFacility.Name;
     156            Facility.Phone = healthFacility.Phone;
     157            Facility.Type = healthFacility.Type;
     158            await _context.SaveChangesAsync();
     159        }
     160
     161        public async Task RemoveMedicine(Medicine medicine)
     162        {
     163            await Task.Run(() => _context.Medicines.Remove(medicine));
     164            await _context.SaveChangesAsync();
     165        }
     166
     167        public async Task UpdatePandemic(Pandemic pandemic)
     168        {
     169            var Pandemic = await Task.Run(() => _context.Pandemics.Where(x => x.Id == pandemic.Id).FirstOrDefault());
     170            Pandemic.ActiveGlobal = pandemic.ActiveGlobal;
     171            Pandemic.ActiveMK = pandemic.ActiveMK;
     172            Pandemic.DeathsGlobal = pandemic.DeathsGlobal;
     173            Pandemic.DeathsMK = pandemic.DeathsMK;
     174            Pandemic.Name = pandemic.Name;
     175            Pandemic.NewMK = pandemic.NewMK;
     176            Pandemic.TotalGlobal = pandemic.TotalGlobal;
     177            Pandemic.TotalMK = pandemic.TotalMK;
     178            await _context.SaveChangesAsync();
     179        }
     180
     181        public async Task RemovePharmacy(Pharmacy pharmacy)
     182        {
     183            await Task.Run(() => _context.Pharmacies.Remove(pharmacy));
     184            await _context.SaveChangesAsync();
     185        }
     186        //ke vidime
     187        public Task UpdateWorker(HealthcareWorker worker)
     188        {
     189            throw new System.NotImplementedException();
     190        }
     191
     192        public async Task UpadatePharmacy(Pharmacy pharmacy)
     193        {
     194            var Pharmacy = await Task.Run(() => _context.Pharmacies.Where(x => x.Id == pharmacy.Id).FirstOrDefault());
     195            Pharmacy.Name = pharmacy.Name;
     196            Pharmacy.Location = pharmacy.Location;
     197            Pharmacy.WorkAllTime = pharmacy.WorkAllTime;
     198            Pharmacy.Address = pharmacy.Address;
     199            await _context.SaveChangesAsync();
     200        }
     201        //ke vidime
     202        public Task UpdateMedicine(Medicine medicine)
     203        {
     204            throw new System.NotImplementedException();
     205        }
     206
     207        public async Task RemovePharmacyHead(PharmacyHead pharmacyHead)
     208        {
     209            var PHead = await Task.Run(() => _context.PharmacyHeads.Where(x => x.Id == pharmacyHead.Id).FirstOrDefault());
     210            PHead.DeletedOn = pharmacyHead.DeletedOn;
     211            await _context.SaveChangesAsync();
     212        }
     213
    143214    }
    144215}
  • FarmatikoData/FarmatikoRepoInterfaces/IRepository.cs

    r5d02859 r1454207  
    11using FarmatikoData.Models;
     2using System;
     3using System.Collections.Generic;
    24using System.Linq;
     5using System.Text;
    36using System.Threading.Tasks;
    47
     
    811    {
    912        //GET
    10         Task<IQueryable<HealthcareWorkers>> GetAllWorkers();
    11         Task<IQueryable<HealthFacilities>> GetFacilities();
    12         Task<HealthFacilities> GetFacility(int Id);
     13        Task<IQueryable<HealthcareWorker>> GetAllWorkers();
     14        Task<IQueryable<HealthFacility>> GetFacilities();
     15        Task<HealthFacility> GetFacility(int Id);
    1316        Task<Medicine> GetMedicine(int Id);
    1417        Task<IQueryable<Medicine>> GetMedicines();
     
    1619        Task<IQueryable<Pharmacy>> GetPharmacies();
    1720        Task<Pharmacy> GetPharmacy(int id);
    18         Task<HealthcareWorkers> GetWorker(int id);
    19         Task<IQueryable<HealthFacilities>> SearchFacilities(string query);
     21        Task<HealthcareWorker> GetWorker(int id);
     22        Task<IQueryable<HealthFacility>> SearchFacilities(string query);
    2023        Task<IQueryable<Medicine>> SearchMedicines(string query);
    2124        Task<IQueryable<Pharmacy>> SearchPharmacies(string query);
    22         Task<IQueryable<HealthcareWorkers>> SearchWorkers(string query);
     25        Task<IQueryable<HealthcareWorker>> SearchWorkers(string query);
     26        Task<HealthFacility> GetFacilityJSON(string healthFacility);
     27
    2328        //POST
    24         Task AddWorker(HealthcareWorkers worker);
    25         Task AddFacility(HealthFacilities healthFacilities);
     29        Task AddWorker(HealthcareWorker Worker);
     30        Task AddFacility(HealthFacility healthFacility);
    2631        Task AddPharmacy(Pharmacy pharmacy);
    2732        Task AddPharmacyHead(PharmacyHead pharmacyHead);
    2833        Task AddMedicines(Medicine medicine);
    2934        Task AddPandemic(Pandemic pandemic);
     35        Task UpdateFacility(HealthFacility healthFacility);
     36        Task RemoveMedicine(Medicine medicine);
     37        Task UpdatePandemic(Pandemic pandemic);
     38        Task RemovePharmacy(Pharmacy pharmacy);
     39        Task UpdateWorker(HealthcareWorker worker);
     40        Task UpadatePharmacy(Pharmacy pharmacy);
     41        Task UpdateMedicine(Medicine medicine);
     42        Task RemovePharmacyHead(PharmacyHead pharmacyHead);
    3043    }
    3144}
  • FarmatikoData/Models/HealthFacility.cs

    r5d02859 r1454207  
    99namespace FarmatikoData.Models
    1010{
    11     public class HealthFacilities : BaseEntity
     11    public class HealthFacility : BaseEntity
    1212    {
    13         public HealthFacilities() { }
     13        public HealthFacility() { }
    1414        [Required]
    1515        public string Name { get; set; }
     
    2222        public string Email { get; set; }
    2323        public string Phone { get; set; }
    24         public HealthFacilities(string Name, string Municipality, string Address, string Type, string Email, string Phone)
     24        public HealthFacility(string Name, string Municipality, string Address, string Type, string Email, string Phone)
    2525        {
    2626            this.Name = Name;
  • FarmatikoData/Models/HealthcareWorker.cs

    r5d02859 r1454207  
    88namespace FarmatikoData.Models
    99{
    10     public class HealthcareWorkers : BaseEntity
     10    public class HealthcareWorker : BaseEntity
    1111    {
    12         public HealthcareWorkers() { }
     12        public HealthcareWorker() { }
    1313        [Required]
    1414        public string Name { get; set; }
     
    1616        public string Branch { get; set; }
    1717        [Required]
    18         public HealthFacilities Facility { get; set; }
     18        public HealthFacility Facility { get; set; }
    1919        public string Title { get; set; }
    20         public HealthcareWorkers(string Name, string Branch, HealthFacilities Facility, string Title)
     20        public HealthcareWorker(string Name, string Branch, HealthFacility Facility, string Title)
    2121        {
    2222            this.Name = Name;
  • FarmatikoData/Models/PharmacyHead.cs

    r5d02859 r1454207  
    1 using System;
    2 using System.Collections.Generic;
     1using System.Collections.Generic;
    32using System.ComponentModel.DataAnnotations;
    4 using System.Text;
    53using FarmatikoData.Base;
    6 using Microsoft.EntityFrameworkCore;
    74
    85namespace FarmatikoData.Models
Note: See TracChangeset for help on using the changeset viewer.