コード例 #1
0
        public IActionResult ViewRoleAssignment(int id)
        {
            var header   = _AccountRole.GetRoleById(id);
            var accounts = _AccountRole.GetAllAccounts(id)
                           .Select(a => new AccountItem
            {
                Id   = a.Id,
                Name = a.LastName + ", " + a.FirstName
            }).ToList();
            var assigned = _AccountRole.GetAssignmentsByHeaderId(id)
                           .Select(a => new AccountItem
            {
                RecordId = a.Id,
                Id       = a.Account.Id,
                Name     = a.Account.LastName + ", " + a.Account.FirstName,
            }).ToList();
            var model = new AccountRoleAssignmentViewModel
            {
                RoleId           = id,
                Description      = header.Description,
                Accounts         = accounts,
                AssignedAccounts = assigned,
            };

            return(View(model));
        }
コード例 #2
0
 public IActionResult AddRoleAssignment(AccountRoleAssignmentViewModel model)
 {
     if (model.SelectedItems != null)
     {
         var items = new List <int>();
         for (int i = 0; i <= model.SelectedItems.Length - 1; i++)
         {
             items.Add(int.Parse(model.SelectedItems[i].ToString()));
         }
         _AccountRole.AddAccount(model.RoleId, items);
         return(RedirectToAction("ViewRoleAssignment", new { id = model.RoleId }));
     }
     else
     {
         return(RedirectToAction("ViewRoleAssignment", new { id = model.RoleId }));
     }
 }