示例#1
0
        /// <summary>
        /// Ons the post async.
        /// </summary>
        /// <returns>The post async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            if (_logger != null)
            {
                _logger.LogDebug("ChipCardDoors/Create/OnPostAsync");
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyChipCardDoor = new ChipCardDoor();

            if (await TryUpdateModelAsync <ChipCardDoor>(
                    emptyChipCardDoor,
                    "chipcarddoor",                     // Prefix for form value
                    c => c.Number,
                    c => c.LastUpdate).ConfigureAwait(false))
            {
                _context.ChipCardDoor.Add(emptyChipCardDoor);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }

            return(null);
        }
示例#2
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        /// <param name="id">Identifier.</param>
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            _logger.LogDebug($"ChipCardDoors/Edit/OnGetAsync({ id })");

            if (id == null)
            {
                return(NotFound());
            }

            ChipCardDoor = await _context.ChipCardDoor.FindAsync(id).ConfigureAwait(false);

            if (ChipCardDoor == null)
            {
                return(NotFound());
            }

            return(Page());
        }
示例#3
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        /// <param name="id">Identifier.</param>
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            _logger.LogDebug($"ChipCardDoors/Details/OnGetAsync ({ id })");

            if (id == null)
            {
                return(NotFound());
            }

            ChipCardDoor = await _context.ChipCardDoor
                           .Include(c => c.Employee)
                           .Include(d => d.Department)
                           .Include(p => p.Place)
                           .AsNoTracking()
                           .FirstOrDefaultAsync(m => m.ID
                                                == id).ConfigureAwait(false);

            if (ChipCardDoor == null)
            {
                return(NotFound());
            }

            return(Page());
        }