Пример #1
0
        public async Task <IActionResult> Create(NewStyleShop_1.Models.Voucher voucher)
        {
            if (ModelState.IsValid)
            {
                voucher.CreateDate = DateTime.Now;
                _db.Add(voucher);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(voucher));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, NewStyleShop_1.Models.Voucher voucher)
        {
            if (id != voucher.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                voucher.ExpireDate = DateTime.Now;
                _db.Update(voucher);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(voucher));
        }