我有使用实体框架的 c# WEB API - 我试图通过我的角度前端发出放置请求以模拟“签入”功能,但请求未通过。
这是我的 Web api 方法
[HttpPut("checkin/{id}")]
[AuthorizeRoles(Role.Administrator, Role.User)]
public async Task<IActionResult> CheckIn(int id)
{
var reservation = await context.Reservations.FindAsync(id);
var username = User.Identity.Name;
if (reservation == null)
return NotFound();
// Ensure user is checking-in their own reservation and its not already checked-in
if (reservation.UserName == username && reservation.CheckInDate == null)
{
reservation.CheckInDate = DateTime.Now;
var count = await context.SaveChangesAsync();
if (count < 1)
return StatusCode((int)HttpStatusCode.InternalServerError);
}
return Ok();
}
Run Code Online (Sandbox Code Playgroud)
这是我的两个 .ts 文件,其中正在发起请求 - 注意:在第二种方法中,我决定手动传递 ID …
这是我的代码,我不确定为什么抛出错误 - 该方法应该在指针对象上操作并打印出它的值.
主要:
cout<<"Deleted item is: "<<displayRecord(tmp)/*tmp->entry*/<<endl;
void displayRecord(PRecord* pr) {
cout<<"Time: "<<pr->time<<"\tEntry data: \""<<pr->entry<<'"'<<endl;
}
Run Code Online (Sandbox Code Playgroud)
header.h:
#include <iostream>
using namespace std;
struct PRecord {
long time;
string entry;
struct PRecord *link;
};
void displayRecord(PRecord* pr);
Run Code Online (Sandbox Code Playgroud)
我收到此错误: error: no match for 'operator <<
error: no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(& std::cout)), ((const char*)"Deleted item is: ")) << Priority_Queue::displayRecord(tmp)'
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:108: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, …Run Code Online (Sandbox Code Playgroud)