Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoData/FarmatikoRepo/MedicineRepository.cs

    rc406ae5 ra55ef91  
    2121        public IQueryable<Medicine> GetAll()
    2222        {
    23             return _context.Medicines.Take(50).Select(x => new Medicine
    24             {
    25                 Name = x.Name,
    26                 Strength = x.Strength,
    27                 Form = x.Form,
    28                 WayOfIssuing = x.WayOfIssuing,
    29                 Manufacturer = x.Manufacturer,
    30                 Price = x.Price,
    31                 Packaging = x.Packaging
    32             }).OrderBy(x => x.Name);
     23            return _context.Medicines.OrderBy(x => x.Name);
    3324        }
    3425
    3526        public IQueryable<Medicine> GetByManufacturer(string Manufacturer)
    3627        {
    37             return _context.Medicines.Take(50).Where(x => x.Name.Contains(Manufacturer))
    38                 .Select(x => new Medicine
    39                 {
    40                     Name = x.Name,
    41                     Strength = x.Strength,
    42                     Form = x.Form,
    43                     WayOfIssuing = x.WayOfIssuing,
    44                     Manufacturer = x.Manufacturer,
    45                     Price = x.Price,
    46                     Packaging = x.Packaging
    47                 }).OrderBy(x => x.Manufacturer);
     28            return _context.Medicines.Where(x => x.Name.Contains(Manufacturer)).OrderBy(x => x.Manufacturer);
    4829        }
    4930
    5031        public IQueryable<Medicine> GetByName(string Name)
    5132        {
    52             return _context.Medicines.Take(50).Where(medicine => medicine.Name.Contains(Name))
    53                 .Select(x => new Medicine
    54                 {
    55                     Name = x.Name,
    56                     Strength = x.Strength,
    57                     Form = x.Form,
    58                     WayOfIssuing = x.WayOfIssuing,
    59                     Manufacturer = x.Manufacturer,
    60                     Price = x.Price,
    61                     Packaging = x.Packaging
    62                 }).OrderBy(x => x.Name);
     33            return _context.Medicines.Where(medicine => medicine.Name.Contains(Name)).OrderBy(x => x.Name);
    6334        }
    6435
    65         public void Remove(Medicine medicine)
     36        public void Remove(string medicine)
    6637        {
    67             Medicine med = _context.Medicines.Where(medicine => medicine.Name.Equals(medicine.Name)).FirstOrDefault();
    68             if (med != null)
    69             {
    70                 _context.Medicines.Remove(med);
    71                 _context.SaveChangesAsync();
    72             }
    73 
     38            Medicine med = (Medicine)_context.Medicines.Where(medicine => medicine.Name.Equals(medicine));
     39            _context.Medicines.Remove(med);
    7440        }
    7541    }
Note: See TracChangeset for help on using the changeset viewer.