【发布时间】:2020-09-17 02:41:35
【问题描述】:
我正在使用一个非常奇怪的端点,
现在我发布到我的端点的数据是scorecardId 和DashboardConfig,我的其余数据是通过后端填充的,即UserId 和DateCreated,现在我需要做一个获取请求对于特定用户,我做了这样的事情:
#region Public Methods
[HttpGet]
[Route("GetbyUserID")]
[ValidateModel]
public IHttpActionResult GetbyUserID(Guid UserID)
{
UserID = this.GetUserId();
var config = _prefentialDashboardConfigService.GetByUserID(UserID);
return Ok(config);
}
我的模特:
public Guid ScorecardId { get; set; }
public Guid UserId { get; set; }
public DateTime DateCreated { get; set; }
public string DashboardConfig { get; set; }
我的 CRUD:
public PrefentialDashboardConfig GetByUserID(System.Guid UserId, params string[] includes)
{
return Repository.SingleOrDefault<PrefentialDashboardConfig>(config => config.UserId == UserId, includes);
}
}
我的 ICRUD:
T SingleOrDefault<T>(Expression<Func<T, bool>> where, params string[] includes) where T : class;
在我的前端,我只是调用了 get 请求,但它给了我一个 404 resource not found 错误。我在淘汰赛中这样称呼我的终点:
var test = PreferentialProcurementDashboardApi.GetbyUserID();
//For testing purposes
console.log("You got it right!" + JSON.stringify(test));
通过从后端获取的 UserId 将我的数据发送到前端控制台的最佳方式是什么?
【问题讨论】: