コード例 #1
0
        OnPostAsync(long?id)
        {
            string uid = HttpContext.Session.GetString("uid");

            if (uid == null)
            {
                return(RedirectToPage("../../Index"));
            }

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

            TblEmployeeRequestGeneralRecord = await _context.TblEmployeeRequestGeneralRecords.FindAsync(id);

            if (TblEmployeeRequestGeneralRecord != null)
            {
                _context.TblEmployeeRequestGeneralRecords.Remove(TblEmployeeRequestGeneralRecord);

                TblEmployeeRequestEmployeeEditLog t = new TblEmployeeRequestEmployeeEditLog()
                {
                    FldEmployeeRequestEmployeeEditLogDate = DateTime.Now,
                    FldEmployeeRequestUserId                 = Int64.Parse(uid),
                    FldEmployeeRequestEmployeeId             = TblEmployeeRequestGeneralRecord.FldEmployeeRequestEmployeeId,
                    FldEmployeeRequestEmployeeEditLogSection = "General-Delete"
                };

                _context.TblEmployeeRequestEmployeeEditLogs.Add(t);

                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("Index", new { id = TblEmployeeRequestGeneralRecord.FldEmployeeRequestEmployeeId }));
        }
コード例 #2
0
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            string uid = HttpContext.Session.GetString("uid");

            if (uid == null)
            {
                return(RedirectToPage("../../Index"));
            }

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

            TblEmployeeRequestGeneralRecord = await _context.TblEmployeeRequestGeneralRecords
                                              .Include(t => t.FldEmployeeRequestEmployee).FirstOrDefaultAsync(m => m.FldEmployeeRequestGeneralRecordId == id);

            if (TblEmployeeRequestGeneralRecord == null)
            {
                return(NotFound());
            }
            return(Page());
        }