Ignore:
Timestamp:
08/07/20 11:01:25 (4 years ago)
Author:
Mile Jankuloski <mile.jankuloski@…>
Branches:
master
Children:
5d02859
Parents:
ee137aa (diff), c406ae5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://develop.finki.ukim.mk/git/farmatiko

File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoData/FarmatikoRepo/MedicineRepository.cs

    ree137aa r63d885e  
    2121        public IQueryable<Medicine> GetAll()
    2222        {
    23             return _context.Medicines.OrderBy(x => x.Name);
     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);
    2433        }
    2534
    2635        public IQueryable<Medicine> GetByManufacturer(string Manufacturer)
    2736        {
    28             return _context.Medicines.Where(x => x.Name.Contains(Manufacturer)).OrderBy(x => x.Manufacturer);
     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);
    2948        }
    3049
    3150        public IQueryable<Medicine> GetByName(string Name)
    3251        {
    33             return _context.Medicines.Where(medicine => medicine.Name.Contains(Name)).OrderBy(x => x.Name);
     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);
    3463        }
    3564
    36         public void Remove(string medicine)
     65        public void Remove(Medicine medicine)
    3766        {
    38             Medicine med = (Medicine)_context.Medicines.Where(medicine => medicine.Name.Equals(medicine));
    39             _context.Medicines.Remove(med);
     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
    4074        }
    4175    }
Note: See TracChangeset for help on using the changeset viewer.