コード例 #1
0
        public async Task <IActionResult> DeleteConfirmed(Guid id)
        {
            var syncEmployee = await GetDatas().FirstAsync(m => m.ID == id);

            CustomSyncEngine customSyncEngine = new CustomSyncEngine(_context, syncConfiguration);

            customSyncEngine.HookPreDeleteGlobalTimeStamp(syncEmployee);

            _context.Update(syncEmployee);
            //_context.SyncEmployee.Remove(syncEmployee);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
コード例 #2
0
        public async Task <IActionResult> DeleteConfirmed(Guid id)
        {
            var syncEmployeeController = new SyncEmployeeController(_context, syncConfiguration);
            var dependentEmployee      = await syncEmployeeController.GetDatas().Where(w => w.DepartmentID == id).FirstOrDefaultAsync();

            if (dependentEmployee != null)
            {
                throw new Exception($"The data is already used by Employee Name: {dependentEmployee.Name}");
            }

            var syncDepartment = await GetDatas().FirstAsync(m => m.ID == id);

            CustomSyncEngine customSyncEngine = new CustomSyncEngine(_context, syncConfiguration);

            customSyncEngine.HookPreDeleteGlobalTimeStamp(syncDepartment);

            _context.Update(syncDepartment);
            //_context.Departments.Remove(syncDepartment);
            await _context.SaveChangesAsync();

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