コード例 #1
0
        public async Task <IActionResult> Post([FromBody] WebData body)
        {
            await Db.Connection.OpenAsync();

            body.Db = Db;
            await body.InsertAsync();

            return(new OkObjectResult(body));
        }
コード例 #2
0
        public async Task <IActionResult> PutOne(int id, [FromBody] WebData body)
        {
            await Db.Connection.OpenAsync();

            var query  = new WebDataQuery(Db);
            var result = await query.FindOneAsync(id);

            if (result is null)
            {
                return(new NotFoundResult()); //404 Error
            }
            result.Time_Stamp = body.Time_Stamp;
            result.Speed      = body.Speed;
            await result.UpdateAsync();

            return(new OkObjectResult(result));
        }
コード例 #3
0
        /// <summary>
        /// Reads all async values
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private async Task <List <WebData> > ReadAllAsync(DbDataReader reader)
        {
            var data = new List <WebData>();

            using (reader)
            {
                while (await reader.ReadAsync())
                {
                    var datum = new WebData(Db)
                    {
                        Record     = reader.GetInt32(0),
                        Time_Stamp = reader.GetDateTime(1),
                        Speed      = reader.GetDouble(2),
                    };
                    data.Add(datum);
                }
            }
            return(data);
        }
コード例 #4
0
 /// <summary>
 /// Constructor with AppDb passed
 /// </summary>
 /// <param name="db"></param>
 public WebController(AppDb db)
 {
     Db          = db;
     TestData    = new WebData();
     TestData.Db = Db;
 }