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