public async Task <IActionResult> Create(CreateContributorViewModel model)
        {
            if (ModelState.IsValid)
            {
                await _contributorService.CreateAsync(model, GetUserId());

                return(RedirectToAction("Manage"));
            }
            return(View(model));
        }
Beispiel #2
0
        public async Task <int> CreateAsync(CreateContributorViewModel createContributorViewModel, string userId)
        {
            var contributor = new Contributor
            {
                Prefix           = createContributorViewModel.Prefix,
                FirstName        = createContributorViewModel.FirstName,
                MiddleName       = createContributorViewModel.MiddleName,
                LastName         = createContributorViewModel.LastName,
                Credentials      = createContributorViewModel.Credentials,
                Suffix           = createContributorViewModel.Suffix,
                YearOfBirth      = createContributorViewModel.YearOfBirth.GetValueOrDefault(),
                YearOfDeath      = createContributorViewModel.YearOfDeath.GetValueOrDefault(),
                CreatedById      = userId,
                LastModifiedById = userId,
                DateCreated      = DateTime.Now,
                DateLastModified = DateTime.Now
            };

            return(await _contributorRepository.CreateAsync(contributor));
        }