internal static UserRoleWithPermissionsEntity ToEntity(this UserRoleFullInfoModel model, int?id = null) => new UserRoleWithPermissionsEntity { Id = id ?? model.Id, Name = model.Name, Permissions = model.Permissions.Select(item => new UserRolePermissionEntity { PermissionGroupId = item.PermissionGroupId, Permissions = item.Permissions.Sum() }) };
public async Task <ActionResult> AddUserRole([FromBody] UserRoleFullInfoModel model) { return(await Execute(async operation => await userRoleService.AddUserRole(operation, model.ToEntity()))); }
public async Task <ActionResult> UpdateUserRole(int id, [FromBody] UserRoleFullInfoModel model) { return(await Execute(async operation => await userRoleService.UpdateUserRole(operation, model.ToEntity(id)))); }