コード例 #1
0
        public async Task <ActionResult> Create()
        {
            var model = new AmendmentCreateViewModel
            {
                Languages = await _languageDataService.GetAllAsync()
            };

            return(View(model));
        }
コード例 #2
0
        public async Task <ActionResult> Create(AmendmentCreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Languages = await _languageDataService.GetAllAsync();

                return(View(model));
            }

            var amendment = _mapper.Map <Model.DataModel.Amendment>(model);

            amendment.AmendmentBodies.Add(new AmendmentBody
            {
                AmendBody  = model.AmendBody,
                LanguageId = model.PrimaryLanguageId
            });

            await _amendmentService.CreateAsync(amendment, User.UserId());

            return(RedirectToAction(nameof(Index)));
        }