コード例 #1
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,TypeName,Amount,IsActive,Year,CreatedDate,CreatedBy")] BonusType bonusType)
        {
            if (id != bonusType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //_context.Update(bonusType);
                    //await _context.SaveChangesAsync();
                    await bonusTypeRepository.Update(bonusType);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BonusTypeExists(bonusType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bonusType));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,TypeName,Amount,IsActive,Year,CreatedDate,CreatedBy")] BonusType bonusType)
        {
            if (id != bonusType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var userId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                    bonusType.CreatedDate = DateTime.Now;
                    bonusType.CreatedBy   = userId;
                    //_context.Update(bonusType);
                    //await _context.SaveChangesAsync();
                    await bonusTypeRepository.Update(bonusType);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BonusTypeExists(bonusType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bonusType));
        }