Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoServices/Services/MedicineListService.cs

    ra55ef91 rc406ae5  
    55using System.Collections.Generic;
    66using System.Linq;
     7using System.Threading.Tasks;
    78
    89namespace FarmatikoServices.Services
     
    1617        }
    1718
    18         public void Add(MedicineList medicineList)
     19        public async void Add(MedicineList medicineList)
    1920        {
    20             try
    21             {
    22                 if (medicineList != null)
    23                     _medicineListRepository.Add(medicineList);
    24             }
    25             catch (Exception e)
    26             {
    27                 e = new Exception("Can't add the medicine list is null.");
    28                 throw e;
    29             }
     21            if (medicineList != null)
     22                await Task.Run(() => _medicineListRepository.Add(medicineList));
     23            else throw new Exception("Can't add, the medicine list is null.");
    3024        }
    3125
    32         public IQueryable<MedicineList> GetAll()
     26        public async Task<IQueryable<MedicineList>> GetAll()
    3327        {
    34             return _medicineListRepository.GetAll();
     28            return await Task.Run(() => _medicineListRepository.GetAll());
    3529        }
    3630
    37         public ICollection<MedicineList> GetByManufacturer(string Manufacturer)
     31        public async Task<ICollection<MedicineList>> GetByManufacturer(string Manufacturer)
    3832        {
    39             try
    40             {
    41                 if (Manufacturer != null)
    42                 {
    43 
    44                     return _medicineListRepository.GetByManufacturer(Manufacturer);
    45                 }
    46             }
    47             catch (Exception e)
    48             {
    49                 e = new Exception("Can't get name of manufacturer is null");
    50                 throw e;
    51             }
    52             return null;
     33            if (Manufacturer != null)
     34                return await Task.Run(() => _medicineListRepository.GetByManufacturer(Manufacturer));
     35            else throw new Exception("Can't get, name of manufacturer is null");
    5336        }
    5437
    55         public ICollection<MedicineList> GetByName(string Name)
     38        public async Task<ICollection<MedicineList>> GetByName(string Name)
    5639        {
    57             try
    58             {
    59                 if (Name != null)
    60                 {
    61                     return _medicineListRepository.GetByName(Name);
    62                 }
    63             }
    64             catch (Exception e)
    65             {
    66                 e = new Exception("Can't get name is null");
    67                 throw e;
    68             }
    69             return null;
     40            if (Name != null)
     41                return await Task.Run(() => _medicineListRepository.GetByName(Name));
     42            else throw new Exception("Can't get, name is null");
    7043        }
    7144
    72         public void Remove(MedicineList medicineList)
     45        public async void Remove(MedicineList medicineList)
    7346        {
    74             try
    75             {
    76                 if (medicineList != null)
    77                     _medicineListRepository.Remove(medicineList);
    78             }
    79             catch (Exception e)
    80             {
    81                 e = new Exception("Can't remove the medicine list is null.");
    82                 throw e;
    83             }
     47            if (medicineList != null)
     48                await Task.Run(() => _medicineListRepository.Remove(medicineList));
     49            else throw new Exception("Can't remove, the medicine list is null.");
    8450        }
    8551    }
Note: See TracChangeset for help on using the changeset viewer.