Ejemplo n.º 1
0
        // Get one sprKdr based on its sprKdrID (SQL Select)
        public async Task <SprKdr> Pharm_GetOne(int id)
        {
            SprKdr sprKdr     = new SprKdr();
            var    parameters = new DynamicParameters();

            parameters.Add("Id", id, DbType.Int32);
            using (var conn = new SqlConnection(_configuration.Value))
            {
                sprKdr = await conn.QueryFirstOrDefaultAsync <SprKdr>("spsprKdr_GetOne", parameters, commandType : CommandType.StoredProcedure);
            }
            return(sprKdr);
        }
Ejemplo n.º 2
0
 // Update one sprKdr row based on its sprKdrID (SQL Update)
 public async Task <bool> PharmUpdate(SprKdr sprKdr)
 {
     using (var conn = new SqlConnection(_configuration.Value))
     {
         var parameters = new DynamicParameters();
         //parameters.Add("sprKdrID", sprKdr.sprKdrID, DbType.Int32);
         //parameters.Add("Title", sprKdr.Title, DbType.String);
         //parameters.Add("DatePublished", sprKdr.DatePublished, DbType.Date);
         //parameters.Add("IsActive", sprKdr.IsActive, DbType.Boolean);
         await conn.ExecuteAsync("spsprKdr_Update", parameters, commandType : CommandType.StoredProcedure);
     }
     return(true);
 }
Ejemplo n.º 3
0
        // Add (create) a sprKdr table row (SQL Insert)
        public async Task <bool> PharmInsert(SprKdr sprKdr)
        {
            using (var conn = new SqlConnection(_configuration.Value))
            {
                var parameters = new DynamicParameters();
                //parameters.Add("Title", sprKdr.Title, DbType.String);
                //parameters.Add("DatePublished", sprKdr.DatePublished, DbType.Date);
                //parameters.Add("IsActive", sprKdr.IsActive, DbType.Boolean);
                // Stored procedure method
                await conn.ExecuteAsync("spsprKdr_Insert", parameters, commandType : CommandType.StoredProcedure);

                // Raw SQL method
                // const string query = @"INSERT INTO sprKdr (Title, DatePublished, IsActive) VALUES (@Title, @DatePublished, @IsActive)";
                // await conn.ExecuteAsync(query, new { sprKdr.Title, sprKdr.DatePublished, sprKdr.IsActive }, commandType: CommandType.Text);
            }
            return(true);
        }