Ignore:
Timestamp:
02/14/21 17:54:35 (3 years ago)
Author:
Dimitar Slezenkovski <dslezenkovski@…>
Branches:
master
Children:
472dd7e
Parents:
6e6f04b
Message:

Add cron job for updating data, with Quartz.NET

File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoServices/Services/Service.cs

    r6e6f04b rf554983  
    144144            var Pharmacies = await _repository.GetPharmacies();
    145145            List<PharmacyDTO> pharmacies = new List<PharmacyDTO>();
    146            
    147             foreach(var pharm in Pharmacies)
     146
     147            foreach (var pharm in Pharmacies)
    148148            {
    149149                PharmacyDTO pharmacyDTO = new PharmacyDTO()
     
    222222            List<PharmacyDTO> pharmacies = new List<PharmacyDTO>();
    223223            var heads = await _phrepo.GetPharmacyHeadInfo();
    224            
     224
    225225            foreach (var pharm in SearchQuery)
    226226            {
     
    232232                    WorkAllTime = pharm.WorkAllTime
    233233                };
    234                
    235                 foreach(var head in heads.ToList())
     234
     235                foreach (var head in heads.ToList())
    236236                {
    237237                    if (head.Pharmacies.Contains(pharm))
     
    241241                    }
    242242                }
    243                
     243
    244244                pharmacies.Add(pharmacyDTO);
    245245            }
     
    256256        //POST (ADD NEW OBJECTS)
    257257        //za json(Sys updateer)
    258         public async Task AddFacility(HealthFacility healthFacilities)
    259         {
    260             if (healthFacilities != null)
    261                 await _repository.AddFacility(healthFacilities);
     258        public async Task AddFacility(HealthFacility healthFacility)
     259        {
     260            if (healthFacility != null)
     261            {
     262                var facilities = await _repository.GetFacilities();
     263                if (!facilities.Contains(healthFacility))
     264                {
     265                    await _repository.AddFacility(healthFacility);
     266                }
     267                else throw new Exception("The facility already exists.");
     268            }
    262269            else throw new Exception("Facility is null");
    263270        }
     
    266273        {
    267274            if (medicine != null)
    268                 await _repository.AddMedicines(medicine);
     275            {
     276                var medicines = await _repository.GetMedicinesAsync();
     277                if (!medicines.Contains(medicine))
     278                    await _repository.AddMedicines(medicine);
     279                else throw new Exception("Medicine already exists.");
     280            }
    269281            else throw new Exception("Medicine is null");
    270282        }
     
    277289        }
    278290        // Samo PharmacyHead i Admin imaat pristap
    279         public void AddPharmacy(Pharmacy pharmacy)
     291        public async void AddPharmacy(Pharmacy pharmacy)
    280292        {
    281293            if (pharmacy != null)
    282                 _repository.AddPharmacy(pharmacy);
     294            {
     295                var pharmacies = await _repository.GetPharmacies();
     296                if (!pharmacies.Contains(pharmacy))
     297                    await _repository.AddPharmacy(pharmacy);
     298                else throw new Exception("Pharmacy already exists.");
     299            }
    283300            else throw new Exception("Pharmacy is null");
    284301        }
    285302
    286303        // Ovaa kontrola ja ima samo admin
    287        
     304
    288305        public async Task<bool> AddPharmacyHead(PharmacyHeadDto pharmacyHead)
    289306        {
     
    324341        {
    325342            if (worker != null)
    326                 await _repository.AddWorker(worker);
     343            {
     344                var workers = await _repository.GetAllWorkers();
     345                if (!workers.Contains(worker))
     346                    await _repository.AddWorker(worker);
     347                else throw new Exception("Worker already exists.");
     348            }
    327349            else throw new Exception("Worker is null");
    328350        }
Note: See TracChangeset for help on using the changeset viewer.