Example #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Shop = await _context.Shop
                   .Include(s => s.City)
                   .AsNoTracking()
                   .FirstOrDefaultAsync(m => m.Id == id);

            if (Shop == null)
            {
                return(NotFound());
            }
            Agent = await _context.Agent.Where(a => a.ShopId == id).ToListAsync();

            Schedule = await _context.Schedule.Where(s => s.ShopId == id).ToListAsync();

            Service = await _context.Service.Where(s => s.ShopId == id).ToListAsync();

            foreach (var ag in Agent)
            {
                ServiceInput.Add(InputServiceModel.ServiceToInputModel(Service.ToList(), ag.SevicesList));
            }
            return(Page());
        }
Example #2
0
        public async Task <IActionResult> OnGet()
        {
            var shop = await _context.Shop.Where(s => s.E_mail == _userManager.GetUserName(User)).Include(s => s.Services).FirstOrDefaultAsync();

            Service = InputServiceModel.ServiceToInputModel(shop.Services.ToList());
            return(Page());
        }
Example #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            int v = await _context.Shop.Where(s => s.E_mail == _userManager.GetUserName(User)).Select(s => s.Id).FirstOrDefaultAsync();

            Agent.ShopId      = v;
            Agent.SevicesList = InputServiceModel.ServiceListToString(Service);
            _context.Agent.Add(Agent);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Example #4
0
        public async Task OnGetAsync()
        {
            int v = _context.Shop.Where(s => s.E_mail == _userManager.GetUserName(User)).Select(s => s.Id).FirstOrDefault();

            Agent = await _context.Agent
                    .Where(a => a.ShopId == v)
                    .AsNoTracking().ToListAsync();

            var service = _context.Service
                          .Where(s => s.ShopId == v)
                          .Include(a => a.Shop)
                          .AsNoTracking().ToList();

            foreach (var ag in Agent)
            {
                Service.Add(InputServiceModel.ServiceToInputModel(service, ag.SevicesList));
            }
        }