Last change
on this file since 4e72684 was 4e72684, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago |
Add services
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[37c8d1d] | 1 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
| 2 | using FarmatikoData.Models;
|
---|
| 3 | using System.Collections.Generic;
|
---|
| 4 | using System.Linq;
|
---|
| 5 |
|
---|
| 6 | namespace FarmatikoData.FarmatikoRepo
|
---|
| 7 | {
|
---|
| 8 | public class MedicineRepository : IMedicineRepository
|
---|
| 9 | {
|
---|
| 10 | private FarmatikoDataContext _context;
|
---|
| 11 | public MedicineRepository(FarmatikoDataContext context)
|
---|
| 12 | {
|
---|
| 13 | _context = context;
|
---|
| 14 | }
|
---|
| 15 | public void Add(Medicine Medicine)
|
---|
| 16 | {
|
---|
| 17 | _context.Add(Medicine);
|
---|
| 18 | _context.SaveChangesAsync();
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | public IEnumerable<Medicine> GetAll()
|
---|
| 22 | {
|
---|
[4e72684] | 23 | return _context.Medicines.OrderBy(x => x.Name);
|
---|
[37c8d1d] | 24 | }
|
---|
| 25 |
|
---|
[e42f61a] | 26 | public IEnumerable<Medicine> GetByManufacturer(string Manufacturer)
|
---|
[37c8d1d] | 27 | {
|
---|
[e42f61a] | 28 | return _context.Medicines.Where(x => x.Name.Contains(Manufacturer)).OrderBy(x => x.Manufacturer);
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | public IEnumerable<Medicine> GetByName(string Name)
|
---|
| 32 | {
|
---|
[4e72684] | 33 | return _context.Medicines.Where(medicine => medicine.Name == Name);
|
---|
[37c8d1d] | 34 | }
|
---|
| 35 |
|
---|
| 36 | public void Remove(string medicine)
|
---|
| 37 | {
|
---|
| 38 | Medicine med = (Medicine)_context.Medicines.Where(medicine => medicine.Name.Equals(medicine));
|
---|
[4e72684] | 39 | _context.Medicines.Remove(med);
|
---|
[37c8d1d] | 40 | }
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.