Esempio n. 1
0
        public async Task <IActionResult> Add()
        {
            var model = new AbonamentViewModel()
            {
            };

            model.AccessDays = GetSelectListItems();
            ViewBag.Title    = "Új bérlet hozzáadása";
            ViewBag.Action   = nameof(Add);
            return(View("Add", model));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(AbonamentViewModel model)
        {
            var accessDays      = GetAccessDays(model.AccessDays);
            var abonamentFromDb = await _context.BasicAbonaments.FirstOrDefaultAsync(x => x.Id == model.Id);

            abonamentFromDb.Name              = model.Name;
            abonamentFromDb.Description       = model.Description;
            abonamentFromDb.Type              = model.Type;
            abonamentFromDb.CompanyId         = 1;
            abonamentFromDb.Constraints       = accessDays;
            abonamentFromDb.AccessLimitPerDay = model.AccessLimitPerDay;


            _context.BasicAbonaments.Update(abonamentFromDb);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 3
0
        public async Task <IActionResult> Add(AbonamentViewModel model)
        {
            var            accessDays = GetAccessDays(model.AccessDays);
            BasicAbonament abonament  = new BasicAbonament()
            {
                Name              = model.Name,
                Description       = model.Description,
                Type              = model.Type,
                CompanyId         = 1,
                Constraints       = accessDays,
                AccessLimitPerDay = model.AccessLimitPerDay,
            };

            _context.BasicAbonaments.Add(abonament);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id)
        {
            var model = await _context.BasicAbonaments.FirstOrDefaultAsync(x => x.Id == id);

            var modelView = new AbonamentViewModel()
            {
                Name              = model.Name,
                Description       = model.Description,
                Type              = model.Type,
                CompanyId         = 1,
                Constraints       = model.Constraints,
                AccessLimitPerDay = model.AccessLimitPerDay,
            };

            modelView.AccessDays = GetNewSelectListItems(model.Constraints);
            ViewBag.Title        = "Bérlet szerkesztése";
            ViewBag.Action       = nameof(Edit);
            return(View("Edit", modelView));
        }