Ignore:
Timestamp:
07/31/20 10:15:02 (4 years ago)
Author:
DimitarSlezenkovski <dslezenkovski@…>
Branches:
master
Children:
d8fafb8
Parents:
4e72684
Message:

Update & add service

File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoServices/Services/MedicineService.cs

    r4e72684 ra55ef91  
    22using FarmatikoData.Models;
    33using FarmatikoServices.FarmatikoServiceInterfaces;
     4using System;
    45using System.Collections.Generic;
     6using System.Linq;
    57
    68namespace FarmatikoServices.Services
     
    1618        public void Add(Medicine medicine)
    1719        {
    18             _medicineRepository.Add(medicine);
     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            }
    1930        }
    2031
    21         public IEnumerable<Medicine> GetAll()
     32        public IQueryable<Medicine> GetAll()
    2233        {
    2334            return _medicineRepository.GetAll();
    2435        }
    2536
    26         public IEnumerable<Medicine> GetByManufacturer(string Manufacturer)
     37        public IQueryable<Medicine> GetByManufacturer(string Manufacturer)
    2738        {
    28             return _medicineRepository.GetByManufacturer(Manufacturer);
     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;
    2951        }
    3052
    31         public IEnumerable<Medicine> GetByName(string Name)
     53        public IQueryable<Medicine> GetByName(string Name)
    3254        {
    33             return _medicineRepository.GetByName(Name);
     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;
    3466        }
    3567
    3668        public void Remove(string Medicine)
    3769        {
    38             _medicineRepository.Remove(Medicine);
     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            }
    3980        }
    4081    }
Note: See TracChangeset for help on using the changeset viewer.