我有一个asp.net web api.
我想稍后在一个天蓝色的网站上拥有我的Web API.
登录用户可以在浏览器中执行此操作 /api/bankaccounts/3
让所有的细节有关bank account number 3.
但登录的用户不是所有者bank account number 3.
我如何设计我的控制器和记录后面的服务
用户只能在数据库中检索/修改自己的资源?
UPDATE
我创建了一个:
public class UserActionsAuthorizationFilter : AuthorizationFilterAttribute
{
   public override void OnAuthorization(HttpActionContext actionContext)
   {
       if (actionContext != null)
       { 
           bool canUserExecuteAction = IsResourceOwner(actionContext);
           // stop propagation  
       }
   }
private bool IsResourceOwner(HttpActionContext actionContext)
        {
            var principal = (ClaimsPrincipal)Thread.CurrentPrincipal; 
            var userIdAuthenticated = Convert.ToInt32(principal.Claims.Single(c => c.Type == ClaimTypes.Sid).Value);
            int targetId = Convert.ToInt32(actionContext.Request.GetRouteData().Values["Id"]);
            var requstScope = actionContext.ControllerContext.Request.GetDependencyScope();
            var service = (ISchoolyearService)requstScope.GetService(typeof(ISchoolyearService)); …Run Code Online (Sandbox Code Playgroud) 如何集成.DefaultIfEmpty()扩展方法,所以我不能使用
.FirstOrDefault() ?? String.Empty;
Run Code Online (Sandbox Code Playgroud)
码:
(from role in roleList
let roleArray = role.RoleId.Split(new char[] { WorkflowConstants.WorkflowRoleDelimiter })
where roleArray.Length.Equals(_SplittedRoleIdArrayLength) && 
      HasAccessToCurrentUnit(roleArray[_UnitIndexInRoleId])
select roleArray[_LevelIndexInRoleId]).FirstOrDefault() ?? String.Empty;
Run Code Online (Sandbox Code Playgroud) 我知道我可以将我的枚举放在类的Namespace区域,这样每个人都可以在同一名称空间中访问它.
// defined in class2
public enum Mode { Selected, New, }  
Run Code Online (Sandbox Code Playgroud)
我想要的是从中访问此枚举
public class1
{
   var class2 = new class2();
   // Set the Mode
   class2.Mode = Model.Selected
}
Run Code Online (Sandbox Code Playgroud)
如果不使用命名空间区域,这是否可行?
我的订单类有:
public int CustomerId { get; set; }
public Customer Customer { get; set; }
Run Code Online (Sandbox Code Playgroud)
我真的需要这两个属性来建立关系吗?
我没有使用断开连接的实体,我使用代码第一种方法.
c# entity-framework foreign-keys ef-code-first entity-framework-5
如何从我的index.html所在的wwwroot访问visual studio解决方案文件中未包含的node_modules文件夹.那个index.html文件需要引用像angular.js这样的npm安装包.
但是怎么样?
我不想将整个node_modules文件夹复制到wwwroot中.那些不是那里的文件......
我不想将node_modules文件夹包含在解决方案中,因为这会减慢所有内容并挂断...
似乎Frontend开发不属于VS ......
npm node-modules asp.net-core-mvc asp.net-core asp.net-core-1.0
有4个Expander控件.当一个扩展器扩展时,我怎么能让所有其他扩展器崩溃/关闭?
为什么在调试此代码时,GETDATE()是一个无效的标识符,表示Oracle Sql Developer工具:
CREATE OR REPLACE TRIGGER SPName
AFTER UPDATE
ON TableName 
FOR EACH ROW
BEGIN
    UPDATE TableName SET LastModifiedDate = GETDATE() WHERE TableName.DET_ID = :new.DET_ID;
END;
Run Code Online (Sandbox Code Playgroud) 当我将SQL参数添加p到集合时,我得到一个InvalidCastException带有帖子标题的消息.
parentId 是数据库中的可空整数和可空整数.
为什么我会得到这个例外,我该如何解决?
我不使用存储过程,我已经读过类似的线程,但他们没有帮助我.
var p = new SqlParameter("ParentId", SqlDbType.Int).Value = parentId ?? (object) DBNull.Value;
cmd.Parameters.Add(p);  
Run Code Online (Sandbox Code Playgroud) http配置通常在启动类中设置,该类绑定到Create方法.
但是,如果我想要的东西,以启动一个owin服务器一次对于所有的测试,但更新取决于每个测试需求的HTTP配置?
这是不可能的.服务器对象没什么用处.
using (var server = TestServer.Create<Startup>())
{
    var data = server.HttpClient.GetAsync("/api/data);
}
Run Code Online (Sandbox Code Playgroud)
我想要为CRUD集成测试做什么是存根服务方法
// Do it ONE time fall ALL tests
WebApiConfig.Register(config);
WebServicesConfig.Register(config);
// Do it individually for each test, Update DI registerations with Fake components per test method
var builder = new ContainerBuilder();
var mockContext = new Mock<TGBContext>();
var mockService = new Mock<SchoolyearService>(mockContext.Object); 
mockService.Setup<Task<IEnumerable<SchoolyearDTO>>>(c => c.GetSchoolyearsAsync()).Returns(Task.FromResult(Enumerable.Empty<SchoolyearDTO>()));
// builder.RegisterInstance<TGBContext>(); ****** NO NEED for this it works without registering the ctor parameter dependency …Run Code Online (Sandbox Code Playgroud) 我想在一个包含6列的DataGrid中使用max 3000项过滤ObservableCollection.用户应该能够以"&&"方式过滤所有6列.
我应该使用LINQ还是CollectionView?LINQ似乎更快尝试一些www样本.你有任何赞成/缺点吗?
更新:
private ObservableCollection<Material> _materialList;
        private ObservableCollection<Material> _materialListInternal;
        public MaterialBrowserListViewModel()
        {           
              _materialListInternal = new ObservableCollection<Material>();          
            for (int i = 0; i < 2222; i++)
            {
                var mat = new Material()
                {
                    Schoolday = DateTime.Now.Date,
                    Period = i,
                    DocumentName = "Excel Sheet" + i,
                    Keywords = "financial budget report",
                    SchoolclassCode = "1",
                };
                _materialListInternal.Add(mat);
                var mat1 = new Material()
                {
                    Schoolday = DateTime.Now.Date,
                    Period = i,
                    DocumentName = "Word Doc" + i,
                    Keywords = "Economical staticstics report",
                    SchoolclassCode …Run Code Online (Sandbox Code Playgroud) c# ×6
linq ×2
wpf ×2
ado.net ×1
asp.net-core ×1
collapse ×1
datagrid ×1
enums ×1
expander ×1
filter ×1
foreign-keys ×1
function ×1
node-modules ×1
npm ×1
oracle ×1
owin ×1
sql ×1
sqlparameter ×1
triggers ×1