示例#1
0
        public async Task <IActionResult> Create(SectionCreateInputModel input)
        {
            var user = await this.userManager.GetUserAsync(this.User);

            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var sectionParentId =
                input.SectionParentId == 0
                ? (int?)null
                : input.SectionParentId;

            var sectionId = await this.sectionsService.CreateAsync(input.Name, input.DepartmentId, sectionParentId, user.Id);

            return(this.RedirectToAction(nameof(this.Details), new { id = sectionId }));
        }
示例#2
0
        public IActionResult Create()
        {
            var departments = this.departmentsService.GetAll <DepartmentDropDownViewModel>()
                              .Prepend(new DepartmentDropDownViewModel
            {
                Name = string.Empty,
                Id   = 0,
            });
            var sections = this.sectionsService.GetAll <SectionDropDownViewModel>()
                           .Prepend(new SectionDropDownViewModel
            {
                Name = string.Empty,
                Id   = 0,
            });

            var viewModel = new SectionCreateInputModel
            {
                Departments = departments,
                Sections    = sections,
            };

            return(this.View(viewModel));
        }