public async Task<IActionResult> Create(SafeViewModel model)
 {
     if (ModelState.IsValid)
     {
         await _safeService.CreateSafe(model);
         return RedirectToAction(nameof(Index));
     }
     return View(model);
 }
Пример #2
0
        public async Task CreateSafe(SafeViewModel viewModel)
        {
            string userId = _identityResolver.GetCurrentUserId();
            var safe = new Safe()
            {
                SubjectName = viewModel.SubjectName,
                AdministratorId = userId,
                CreatedById = userId
            };

            _dbContext.Safes.Add(safe);
            await _dbContext.SaveChangesAsync();
        }