Ignore:
Timestamp:
08/05/20 18:39:58 (2 years ago)
Author:
DimitarSlezenkovski <dslezenkovski@…>
Branches:
master
Children:
63d885e
Parents:
a6bbad1
Message:

Update Models, Repos, Services and Controllers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoServices/Services/PandemicService.cs

    ra6bbad1 rc406ae5  
    44using System;
    55using System.Linq;
     6using System.Threading.Tasks;
    67
    78namespace FarmatikoServices.Services
     
    1516        }
    1617
    17         public void Add(Pandemic pandemic)
     18        public async void Add(Pandemic pandemic)
    1819        {
    19             try
    20             {
    21                 if (pandemic != null)
    22                 {
    23                     _pandemicRepository.Add(pandemic);
    24                 }
    25             }
    26             catch (Exception e)
    27             {
    28                 e = new Exception("Can't add pandemic is null.");
    29                 throw e;
    30             }
     20            if (pandemic != null)
     21                await Task.Run(() => _pandemicRepository.Add(pandemic));
     22            else throw new Exception("Can't add pandemic is null.");
    3123        }
    3224
    33         public IQueryable<Pandemic> GetAll()
     25        public async Task<IQueryable<Pandemic>> GetAll()
    3426        {
    35             return _pandemicRepository.GetAll();
     27            return await Task.Run(() => _pandemicRepository.GetAll());
    3628        }
    3729
    38         public void Remove(Pandemic pandemic)
     30        public async void Remove(Pandemic pandemic)
    3931        {
    40             try
    41             {
    42                 if (pandemic != null)
    43                     _pandemicRepository.Remove(pandemic);
    44             }
    45             catch (Exception e)
    46             {
    47                 e = new Exception("Can't remove, pandemic is null.");
    48             }
     32            if (pandemic != null)
     33                await Task.Run(() => _pandemicRepository.Remove(pandemic));
     34            else throw new Exception("Can't remove, pandemic is null.");
    4935        }
    5036    }
Note: See TracChangeset for help on using the changeset viewer.