本文整理汇总了C#中RoleViewModel类的典型用法代码示例。如果您正苦于以下问题:C# RoleViewModel类的具体用法?C# RoleViewModel怎么用?C# RoleViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoleViewModel类属于命名空间,在下文中一共展示了RoleViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRoles
public ActionResult AddRoles(Guid productId, string version, string error = null)
{
if(error != null)
{
ModelState.AddModelError("", error);
}
var product = _productRepository.Find(productId);
var currentRoles = product.Versions.Single(x => x.Name == version).Roles.Select(x => x.Name);
var baseImages = _baseImageRepository.FindAll().ToDictionary(x => x.Id, x => x.Name);
var model = new RoleViewModel
{
ProductId = productId,
ProductName = product.Name,
VersionName = version,
BaseImages = baseImages,
Ports = new List<PortViewModel> { new PortViewModel { DnsTtl = 3600}},
CurrentRoles = currentRoles.ToList(),
VolumeSize = 60,
InstanceTypes = _stackItConfiguration.InstanceTypes.Select(x => x.Name).ToList()
};
return View(model);
}
示例2: ManageRole
public ActionResult ManageRole(RoleViewModel model)
{
if (model.Role == null)
{
model.Role = new Role();
}
if (!string.IsNullOrEmpty(model.Role.sort))
{
model.Role.SortExp = model.Role.sort + " " + model.Role.sortdir;
}
if (model.Role.PageSize == 0)
{
int PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
model.Role.PageSize = PageSize;
}
if (model.Role.PageIndex == 0)
{
model.Role.PageIndex = 1;
}
model.RoleList = new List<Role>();
model.Role.TotalCount = 0;
model.RoleList = _IRoleService.GetAll(model.Role).ToList();
if (model.RoleList != null && model.RoleList.Count > 0)
{
int TotalCount = model.RoleList[0].TotalCount;
model.Role.TotalCount = TotalCount;
}
return View(model);
}
示例3: getRoleFromId
public RoleViewModel getRoleFromId(string id)
{
var db = new BwareContext();
var roleViewModel = new RoleViewModel();
roleViewModel = db.AspNetRoles.Where(r => r.Name == id).Select(r => new RoleViewModel() { CurrentName = r.Name }).FirstOrDefault();
return roleViewModel;
}
示例4: ToViewModel
public static RoleViewModel ToViewModel(IdentityRole Role)
{
var roleViewModel = new RoleViewModel()
{
Id = Role.Id,
Name = Role.Name
};
return roleViewModel;
}
示例5: Create
/// <summary>
/// 新增角色
/// </summary>
/// <returns></returns>
public ActionResult Create()
{
var viewModel = new RoleViewModel
{
MenuCheckList = roleService.GetMenuByRoleId(null)
};
return View(viewModel);
}
示例6: GetAllRoles
public List<RoleViewModel> GetAllRoles()
{
var rolesList = new List<RoleViewModel>();
foreach (var role in _db.Roles)
{
var roleModel = new RoleViewModel(ConvertRole(role));
rolesList.Add(roleModel);
}
return rolesList;
}
示例7: ToViewModel
public static RoleViewModel ToViewModel(this Model.Role rolePOCO)
{
var roleViewModel = new RoleViewModel();
return new RoleViewModel()
{
roleID = rolePOCO.roleID,
roleName = rolePOCO.roleName,
};
}
示例8: Modify
public ActionResult Modify(int id, RoleViewModel viewmodel)
{
if (ModelState.IsValid)
{
viewmodel.roleID =id ;
OperationContext.ServiceSession.RoleService.Update(viewmodel.ToPOCO(), "roleName", "roleIsDeleted");
OperationContext.ServiceSession.SaveChange();
return OperationContext.SendAjaxMessage(AjaxMessageStatus.OperationSuccess, "", "", null);
}
return OperationContext.SendAjaxMessage(AjaxMessageStatus.OperationFailed, "Please enable javascript in the browser", "", null);
}
示例9: Edit
public ActionResult Edit(RoleViewModel vmChanged)
{
var vm = GetViewModelFromTempData<RoleViewModel>();
if (vm == null) { return RedirectToReferrer(); }
vm.DisplayName = Strings.RoleDetailView_Title;
vm.LatestControllerAction = ControllerAction.Edit;
vm.ApplyFormAttributes(vmChanged.SelectedItem);
return StoreEntity(vm);
}
示例10: Edit
public async Task<ActionResult> Edit(string id)
{
if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
var role = await IdentityRepository.RoleManager.FindByIdAsync(id);
if (role == null) return HttpNotFound();
RoleViewModel roleModel = new RoleViewModel { Id = role.Id, Name = role.Name };
return View(roleModel);
}
示例11: ToViewModel
public static RoleViewModel ToViewModel(this IdentityRole role)
{
string Editor = "<a class='btn btn-success' href='javascript:void(0);'><i class='fa fa-cog'></i> 编辑</a>";
string Delete = "<a class='btn btn-danger' href='javascript:void(0);'><i class='fa fa-remove'></i> 删除</a></td>";
RoleViewModel model = new RoleViewModel()
{
Id = role.Id,
Name = role.Name,
Other = string.Format(Delete+Editor),
};
return model;
}
示例12: Create
public async Task<ActionResult> Create(RoleViewModel roleViewModel) {
if (ModelState.IsValid) {
var role = new IdentityRole(roleViewModel.Name);
var roleresult = await RoleManager.CreateAsync(role);
if (!roleresult.Succeeded) {
ModelState.AddModelError("", roleresult.Errors.First());
return View();
}
return RedirectToAction("Index");
}
return View();
}
示例13: Add
public ActionResult Add(RoleViewModel viewModel)
{
if (ModelState.IsValid)
{
OperationContext.ServiceSession.RoleService.Add(viewModel.ToPOCO());
OperationContext.ServiceSession.SaveChange();
return OperationContext.SendAjaxMessage(AjaxMessageStatus.OperationSuccess, "", "", null);
}
else
{
return OperationContext.SendAjaxMessage(AjaxMessageStatus.OperationFailed, "Please enable javascript in browser.", "", null);
}
}
示例14: Add
public ActionResult Add(RoleViewModel model)
{
if (!this.ModelState.IsValid)
{
return this.View(model);
}
this.roles.Add(model.Name);
this.SetTempDataSuccessMessage(string.Format("The role {0} was added successfully!", model.Name));
return this.RedirectToAction("Index", "Roles");
}
示例15: Create
public async Task<ActionResult> Create(RoleViewModel roleViewModel)
{
if (!ModelState.IsValid) return View();
var role = new IdentityRole(roleViewModel.Name);
IdentityResult result = await IdentityRepository.RoleManager.CreateAsync(role);
IsResultNotSucceededAddModelError(result);
if (result.Succeeded) return RedirectToAction("Index");
return View();
}