public IActionResult EditEntityPermission(EditEntityPermissionModel model) { if (!Arguments.HasValue(model.EntityId)) { return(NotFound()); } if (ModelState.IsValid) { EntityPermission entity = new EntityPermission(); model.CopyTo(entity); if (!entity.EntityPermissionId.Equals(Guid.Empty)) { return(_entityPermissionService.Update(entity).UpdateResult(T)); } else { entity.EntityPermissionId = Guid.NewGuid(); return(_entityPermissionService.Create(entity).CreateResult(T)); } } return(SaveFailure(GetModelErrors())); }
public IActionResult EditEntityPermission(Guid?id) { EditEntityPermissionModel model = new EditEntityPermissionModel(); if (id.HasValue && !id.Value.Equals(Guid.Empty)) { var entity = _entityPermissionService.FindById(id.Value); if (entity != null) { entity.CopyTo(model); } else { return(NotFound()); } } else { model.State = RecordState.Enabled; } List <SelectListItem> types = new List <SelectListItem>(); types.Add(new SelectListItem() { Text = T["security_read"], Value = (AccessRightValue.Read).ToString() }); types.Add(new SelectListItem() { Text = T["security_create"], Value = (AccessRightValue.Create).ToString() }); types.Add(new SelectListItem() { Text = T["security_update"], Value = (AccessRightValue.Update).ToString() }); types.Add(new SelectListItem() { Text = T["security_delete"], Value = (AccessRightValue.Delete).ToString() }); types.Add(new SelectListItem() { Text = T["security_share"], Value = (AccessRightValue.Share).ToString() }); types.Add(new SelectListItem() { Text = T["security_assign"], Value = (AccessRightValue.Assign).ToString() }); types.Add(new SelectListItem() { Text = T["security_import"], Value = (AccessRightValue.Import).ToString() }); types.Add(new SelectListItem() { Text = T["security_export"], Value = (AccessRightValue.Export).ToString() }); types.Add(new SelectListItem() { Text = T["security_append"], Value = (AccessRightValue.Append).ToString() }); types.Add(new SelectListItem() { Text = T["security_appendto"], Value = (AccessRightValue.AppendTo).ToString() }); model.PermissionTypes = new SelectList(types, "value", "text"); return(View($"~/Views/Security/{WebContext.ActionName}.cshtml", model)); }