public async Task <IActionResult> Create([FromBody] FoodOrderCreateDto order) { if (!User.IsInRole("Admin") && !order.IsMe) { return(BadRequest("Only admin can specify OtherPersonName.")); } int?userId = await GetUserIdFromUserName(order.IsMe, order.OtherPersonName); if (userId == null) { return(BadRequest($"User {order.OtherPersonName} cannot found.")); } FoodOrder foodOrder = await order.Create(_db, userId.Value, new FoodOrderClientInfo { Ip = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString(), UserAgent = $"{Request.Host}@{Request.Headers["User-Agent"]}" }); await _newOrderHubContext.OnNewOrder(foodOrder.Id); return(Ok()); }