示例#1
0
        //[HttpGet]
        //public async Task<IActionResult> Index()

        //{
        //    var words = from word in _context.Drugs
        //                select word;

        //    //_drugRepository.GetAllDrugs();
        //    return View(await words.ToListAsync());
        //}
        //[HttpGet]
        public async Task <IActionResult> Index(string search)
        {
            var y = _drugRepository.GetAllDrugs();
            var x = y.Select(s =>
            {
                return(new Drugs
                {
                    Stores = storeRepository.GetStorebyId(s.StoresId),
                    Name = s.Name,
                    Description = s.Description,
                    Photopath = s.Photopath,
                    StoresId = s.StoresId
                });
            });

            var words = from word in _context.Drugs
                        select word;

            if (!String.IsNullOrEmpty(search))
            {
                words = words.Where(s => s.Name.Contains(search));
            }
            if (words == null)
            {
                return(View());
            }



            return(View(await words.ToListAsync()));
        }
示例#2
0
 /// <summary>
 /// This method is responsible for returing the Drug Details of all drugs available
 /// </summary>
 public List <Drug> GetAllDrugs()
 {
     return(_drugRepository.GetAllDrugs());
 }