public ViewResult Create() { var viewModel = new InsertRoleViewModel { Role = new Role(), Permission = new List<CheckedPermission>() }; foreach (var permission in ReferenceDataCache.PermissionCollection) { viewModel.Permission.Add(new CheckedPermission { Permission = permission }); } return View(viewModel); }
public ActionResult Create(InsertRoleViewModel vm) { if (ModelState.IsValid) { IList<int> p = (from t in vm.Permission where t.IsChecked select t.Permission.Id).ToList(); Feedback<Role> feedback = _repository.InsertRole(vm.Role, p); if (feedback.Success) { // Remove RoleCollection from cache to force reload on next access Cacher.Remove(Constants.ConfigKeys.Caching.RoleCollectionCacheMinutes); SetMessage(Resources.Messages.InsertRoleSuccess, MessageType.Success); return RedirectToAction("Index"); } SetMessage(feedback.Message, MessageType.Error); } return View(vm); }