コード例 #1
0
        public ActionResult Department()
        {
            var model = new DepartmentViewModel();

            PrepareDepartmentViewModel(model);

            return View(model);
        }
コード例 #2
0
        private void PrepareDepartmentViewModel(DepartmentViewModel model)
        {
            model.
                Departments =
                _accountService.Departments.Select(
                    s =>
                        new SelectListItem() { Text = s.Name, Value = s.Id.ToString(CultureInfo.InvariantCulture) })
                    .ToList();

            model.Departments.Insert(0, new SelectListItem() { Text = "-", Value = "" });
        }
コード例 #3
0
        public async Task<ActionResult> Department(DepartmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                _accountService.AddDepartment(new Department()
                {
                    Address = model.Address,
                    ParentId = model.ParentDepartmentId,
                    Name = model.Name
                });
            }

            PrepareDepartmentViewModel(model);

            // If we got this far, something failed, redisplay form
            return View(model);
        }