Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoServices/Services/PharmacyService.cs

    ra55ef91 rc406ae5  
    55using System.Collections.Generic;
    66using System.Linq;
     7using System.Threading.Tasks;
    78
    89namespace FarmatikoServices.Services
     
    1516            _pharmacyRepository = pharmacyRepository;
    1617        }
    17         public void Add(Pharmacy pharmacy)
     18        public async void Add(Pharmacy pharmacy)
    1819        {
    19             try
    20             {
    21                 if (pharmacy != null)
    22                 {
    23                     _pharmacyRepository.Add(pharmacy);
    24                 }
    25             }
    26             catch (Exception e)
    27             {
    28                 e = new Exception("Can't add, pharmacy has null value.");
    29                 throw e;
    30             }
    31            
     20            if (pharmacy != null)
     21                await Task.Run(() => _pharmacyRepository.Add(pharmacy));
     22            else throw new Exception("Can't add, pharmacy has null value.");
    3223        }
    3324
    34         public IQueryable<Pharmacy> GetAll()
     25        public async Task<IQueryable<Pharmacy>> GetAll()
    3526        {
    36             return _pharmacyRepository.GetAll();
     27            return await Task.Run(() => _pharmacyRepository.GetAll());
    3728        }
    3829
    39         public ICollection<Pharmacy> GetPharmacies()
     30        public async Task<ICollection<Pharmacy>> GetPharmacies()
    4031        {
    41             return _pharmacyRepository.GetPharmacies();
     32            return await Task.Run(() => _pharmacyRepository.GetPharmacies());
    4233        }
    4334
    44         public void Remove(Pharmacy pharmacy)
     35        public async void Remove(Pharmacy pharmacy)
    4536        {
    46             try
    47             {
    48                 if (pharmacy != null)
    49                     _pharmacyRepository.Remove(pharmacy);
    50             }
    51             catch (Exception e)
    52             {
    53                 e = new Exception("Can't remove, pharmacy has null value.");
    54                 throw e;
    55             }
     37            if (pharmacy != null)
     38                await Task.Run(() => _pharmacyRepository.Remove(pharmacy));
     39            else throw new Exception("Can't remove, pharmacy has null value.");
    5640        }
    5741
    58         public void UpdatePharmacy(Pharmacy pharmacy, string Name)
     42        public async void UpdatePharmacy(Pharmacy pharmacy)
    5943        {
    60             try
    61             {
    62                 if (pharmacy != null && Name != null)
    63                 {
    64                     _pharmacyRepository.UpdatePharmacy(pharmacy, Name);
    65                 }
    66             }
    67             catch (Exception e)
    68             {
    69                 e = new Exception("Can not update pharmacy, has null value.");
    70                 throw e;
    71             }
    72            
     44            if (pharmacy != null)
     45                await Task.Run(() => _pharmacyRepository.UpdatePharmacy(pharmacy));
     46            else throw new Exception("Can not update pharmacy, has null value.");
    7347        }
    7448    }
Note: See TracChangeset for help on using the changeset viewer.