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/MedicineListService.cs

    r4e72684 ra55ef91  
    22using FarmatikoData.Models;
    33using FarmatikoServices.FarmatikoServiceInterfaces;
     4using System;
    45using System.Collections.Generic;
     6using System.Linq;
    57
    68namespace FarmatikoServices.Services
     
    1416        }
    1517
    16         public IEnumerable<MedicineList> GetAll()
     18        public void Add(MedicineList medicineList)
     19        {
     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            }
     30        }
     31
     32        public IQueryable<MedicineList> GetAll()
    1733        {
    1834            return _medicineListRepository.GetAll();
     
    2137        public ICollection<MedicineList> GetByManufacturer(string Manufacturer)
    2238        {
    23             return _medicineListRepository.GetByManufacturer(Manufacturer);
     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;
    2453        }
    2554
    2655        public ICollection<MedicineList> GetByName(string Name)
    2756        {
    28             if(Name != null)
     57            try
    2958            {
    30                 return _medicineListRepository.GetByName(Name);
     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;
    3168            }
    3269            return null;
    3370        }
    3471
    35         public bool SetHasMedicine(MedicineList medicineList, bool HasMedicine)
     72        public void Remove(MedicineList medicineList)
    3673        {
    37             if (medicineList != null)
     74            try
    3875            {
    39                 _medicineListRepository.SetHasMedicine(medicineList, HasMedicine);
    40                 return true;
     76                if (medicineList != null)
     77                    _medicineListRepository.Remove(medicineList);
    4178            }
    42             else return false;
     79            catch (Exception e)
     80            {
     81                e = new Exception("Can't remove the medicine list is null.");
     82                throw e;
     83            }
    4384        }
    4485    }
Note: See TracChangeset for help on using the changeset viewer.