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 |
|
---|
| 29 | public Medicine GetByName(string Name)
|
---|
| 30 | {
|
---|
| 31 | return (Medicine)_context.Medicines.Where(medicine => medicine.Name == Name);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public void Remove(string medicine)
|
---|
| 35 | {
|
---|
| 36 | Medicine med = (Medicine)_context.Medicines.Where(medicine => medicine.Name.Equals(medicine));
|
---|
| 37 | _context.Medicines.Remove(med);
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.