public IActionResult Assignment(int id) { var name = _Approver.GetNameById(id); var assigned = _Approver.GetAssignedAccountsById(id) .Select(a => new AssignedAccountViewModel { Id = a.Id, Name = _Approver.GetNameById(a.User.Id), Company = a.User.Company.Description, Branch = a.User.Branch.Description, Department = a.User.Department.Description, Position = a.User.Position.Description, }).ToList(); var accounts = _Approver.GetAccountsById(id) .Select(a => new AccountItemViewModel { Id = a.Id, Name = a.LastName + ", " + a.FirstName }); var model = new ApproverAssignmentViewModel { ApproverId = id, ApproverName = name, AssignedAccounts = assigned, Accounts = accounts }; return(View(model)); }
public IActionResult Assign(ApproverAssignmentViewModel model) { var UserId = HttpContext.Session.GetString("UserId"); if (model.SelectedItems != null) { var items = new List <int>(); for (int i = 0; i <= model.SelectedItems.Length - 1; i++) { var item = int.Parse(model.SelectedItems[i].ToString()); items.Add(item); } _Approver.AssignAccounts(items, model.ApproverId, int.Parse(UserId)); } return(RedirectToAction("Assignment", new { id = model.ApproverId })); }