コード例 #1
0
ファイル: Plane.cshtml.cs プロジェクト: ShikuroD/Greenair
        public async Task <IActionResult> OnPostCreatePlane()
        {
            string       respone = "True";
            MemoryStream stream  = new MemoryStream();

            Request.Body.CopyTo(stream);
            stream.Position = 0;
            using (StreamReader reader = new StreamReader(stream))
            {
                string requestBody = reader.ReadToEnd();
                if (requestBody.Length > 0)
                {
                    var obj = JsonConvert.DeserializeObject <PlaneDTO>(requestBody);
                    if (obj != null)
                    {
                        PlaneDTO plane = new PlaneDTO();
                        // plane.PlaneId = obj.PlaneId;
                        plane.SeatNum = obj.SeatNum;
                        plane.MakerId = obj.MakerId.Substring(0, 3);
                        await _services.addPlaneAsync(plane);
                    }
                }
            }
            return(new JsonResult(respone));
        }