示例#1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("ID,SynchronizationID,Name")] SyncDepartment syncDepartment)
        {
            if (id != syncDepartment.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    syncDepartment.LastUpdated = TempHelper.GetNowTicks();
                    _context.Update(syncDepartment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SyncDepartmentExists(syncDepartment.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(syncDepartment));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("ID,SynchronizationID,Name,Birthday,NumberOfComputers,SavingAmount,IsActive,DepartmentID")] SyncEmployee syncEmployee)
        {
            if (id != syncEmployee.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (syncEmployee.DepartmentID == Guid.Empty)
                    {
                        syncEmployee.DepartmentID = null;
                    }
                    syncEmployee.LastUpdated = TempHelper.GetNowTicks();
                    _context.Update(syncEmployee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SyncEmployeeExists(syncEmployee.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentID"] = GetSelectListDepartment(syncEmployee.DepartmentID);
            return(View(syncEmployee));
        }
        public async Task <IActionResult> DeleteConfirmed(Guid id)
        {
            var syncEmployee = await GetDatas().FirstAsync(m => m.ID == id);

            syncEmployee.Deleted = TempHelper.GetNowTicks();
            _context.Update(syncEmployee);
            //_context.SyncEmployee.Remove(syncEmployee);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("SynchronizationID,Name")] SyncDepartment syncDepartment)
        {
            if (ModelState.IsValid)
            {
                syncDepartment.ID          = Guid.NewGuid();
                syncDepartment.LastUpdated = TempHelper.GetNowTicks();
                _context.Add(syncDepartment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(syncDepartment));
        }
        public async Task <IActionResult> Create([Bind("SynchronizationID,Name,Birthday,NumberOfComputers,SavingAmount,IsActive,DepartmentID")] SyncEmployee syncEmployee)
        {
            if (ModelState.IsValid)
            {
                syncEmployee.ID = Guid.NewGuid();
                if (syncEmployee.DepartmentID == Guid.Empty)
                {
                    syncEmployee.DepartmentID = null;
                }
                syncEmployee.LastUpdated = TempHelper.GetNowTicks();
                _context.Add(syncEmployee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentID"] = GetSelectListDepartment(syncEmployee.DepartmentID);
            return(View(syncEmployee));
        }