Ignore:
Timestamp:
08/07/20 11:01:25 (4 years ago)
Author:
Mile Jankuloski <mile.jankuloski@…>
Branches:
master
Children:
5d02859
Parents:
ee137aa (diff), c406ae5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://develop.finki.ukim.mk/git/farmatiko

File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoServices/Services/MedicineService.cs

    ree137aa r63d885e  
    55using System.Collections.Generic;
    66using System.Linq;
     7using System.Threading.Tasks;
    78
    89namespace FarmatikoServices.Services
     
    1617        }
    1718
    18         public void Add(Medicine medicine)
     19        public async void Add(Medicine medicine)
    1920        {
    20             try
    21             {
    22                 if (medicine != null)
    23                     _medicineRepository.Add(medicine);
    24             }
    25             catch (Exception e)
    26             {
    27                 e = new Exception("Can't Add medicine is null");
    28                 throw e;
    29             }
     21            if (medicine != null)
     22                await Task.Run(() => _medicineRepository.Add(medicine));
     23            else throw new Exception("Can't Add medicine is null");
    3024        }
    3125
    32         public IQueryable<Medicine> GetAll()
     26        public async Task<IQueryable<Medicine>> GetAll()
    3327        {
    34             return _medicineRepository.GetAll();
     28            return await Task.Run(() => _medicineRepository.GetAll());
    3529        }
    3630
    37         public IQueryable<Medicine> GetByManufacturer(string Manufacturer)
     31        public async Task<IQueryable<Medicine>> GetByManufacturer(string Manufacturer)
    3832        {
    39             try
    40             {
    41                 if (Manufacturer != null)
    42                     return _medicineRepository.GetByManufacturer(Manufacturer);
    43             }
    44             catch (Exception e)
    45             {
    46                 e = new Exception("Can't get, name of manufacturer is null");
    47                 throw e;
    48             }
    49            
    50             return null;
     33            if (Manufacturer != null)
     34                return await Task.Run(() => _medicineRepository.GetByManufacturer(Manufacturer));
     35            else throw new Exception("Can't get, name of manufacturer is null");
    5136        }
    5237
    53         public IQueryable<Medicine> GetByName(string Name)
     38        public async Task<IQueryable<Medicine>> GetByName(string Name)
    5439        {
    55             try
    56             {
    57                 if (Name != null)
    58                     return _medicineRepository.GetByName(Name);
    59             }
    60             catch (Exception e)
    61             {
    62                 e = new Exception("Can't get, name is null");
    63             }
    64            
    65             return null;
     40            if (Name != null)
     41                return await Task.Run(() => _medicineRepository.GetByName(Name));
     42            else throw new Exception("Can't get, name is null");
    6643        }
    6744
    68         public void Remove(string Medicine)
     45        public async void Remove(Medicine Medicine)
    6946        {
    70             try
    71             {
    72                 if (Medicine != null)
    73                     _medicineRepository.Remove(Medicine);
    74             }
    75             catch (Exception e)
    76             {
    77                 e = new Exception("Can't Add medicine is null");
    78                 throw e;
    79             }
     47            if (Medicine != null)
     48                await Task.Run(() => _medicineRepository.Remove(Medicine));
     49            else throw new Exception("Can't Add medicine is null");
    8050        }
    8151    }
Note: See TracChangeset for help on using the changeset viewer.