Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,TypeName,Amount,IsActive,Year,CreatedDate,CreatedBy")] BonusTypeViewModel bonusType)
        {
            if (ModelState.IsValid)
            {
                BonusType bb = new BonusType()
                {
                    TypeName    = bonusType.TypeName,
                    Amount      = bonusType.Amount,
                    IsActive    = bonusType.IsActive,
                    Year        = bonusType.Year,
                    CreatedBy   = bonusType.CreatedBy,
                    CreatedDate = bonusType.CreatedDate
                };
                await bonusTypeRepository.Save(bb);

                //_context.Add(bonusType);
                //await _context.SaveChangesAsync();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bonusType));
        }
        public async Task <IActionResult> Create([Bind("Id,TypeName,Amount,IsActive,Year,CreatedDate,CreatedBy")] BonusTypeViewModel bonusType)
        {
            if (ModelState.IsValid)
            {
                var       userId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
                BonusType bb     = new BonusType()
                {
                    TypeName    = bonusType.TypeName,
                    Amount      = bonusType.Amount,
                    IsActive    = false,
                    Year        = "",
                    CreatedBy   = userId,
                    CreatedDate = DateTime.Now
                };
                await bonusTypeRepository.Save(bb);

                //_context.Add(bonusType);
                //await _context.SaveChangesAsync();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bonusType));
        }