public async Task <IActionResult> Create([Bind("Id,Name,AmmountPerDay,Status,CreatedBy,CreatedDate")] AllowanceTypeViewModel allowanceTypes) { if (ModelState.IsValid) { AllowanceType alt = new AllowanceType() { Name = allowanceTypes.Name, AmmountPerDay = allowanceTypes.AmmountPerDay, Status = allowanceTypes.Status, CreatedBy = allowanceTypes.CreatedBy, CreatedDate = DateTime.Now }; await allowanceType.Save(alt); //_context.Add(allowanceType); //await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(allowanceTypes)); }
public async Task <IActionResult> Create([Bind("Id,Name,AmmountPerDay,Status,CreatedBy,CreatedDate")] AllowanceTypeViewModel allowanceTypes) { if (ModelState.IsValid) { var userId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; AllowanceType alt = new AllowanceType() { Name = allowanceTypes.Name, AmmountPerDay = allowanceTypes.AmmountPerDay, Status = allowanceTypes.Status, CreatedBy = userId, CreatedDate = DateTime.Now }; await allowanceType.Save(alt); //_context.Add(allowanceType); //await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(allowanceTypes)); }