Exemple #1
0
        public async Task <IActionResult> Stores()
        {
            var viewModel = new List <DAL.Models.Stores>();

            using (var dbContext = new DAL.Context.DatabaseContext())
            {
                var storeRepository = new DAL.Repositories.StoresRepository(dbContext);

                viewModel           = (await storeRepository.GetAllAsync()).ToList();
                ViewData["Message"] = "Place all the stores in this tabel";
            }
            return(View(viewModel));
        }
        public async Task <IActionResult> Edit(int id)
        {
            using (var dbContext = new DAL.Context.DatabaseContext())
            {
                var StoresRepository = new DAL.Repositories.StoresRepository(dbContext);
                var store            = await StoresRepository.FindAsync(id);

                if (store == null)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                return(View(new StoreViewModel
                {
                    Id = store.Id,
                    Openinghours = store.Openinghours,
                    Closinghours = store.Closinghours,
                    StoreName = store.StoreName,
                    StoreLocation = store.StoreLocation
                }));
            }
        }