This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[assembly: WebJobsStartup(typeof(Startup))] | |
namespace SampleFunctionsApp | |
{ | |
public class Startup : IWebJobsStartup | |
{ | |
public void Configure(IWebJobsBuilder builder) | |
{ | |
builder.Services.AddLogging(loggingBuilder => | |
{ | |
loggingBuilder.AddFilter(level => true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName(nameof(CreateBook))] | |
public async Task<IActionResult> Run( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "CreateBook")] HttpRequest req) | |
{ | |
IActionResult returnValue = null; | |
string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); | |
var input = JsonConvert.DeserializeObject<BookModel>(requestBody); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int Update(BookModel bookModel) | |
{ | |
using (IDbConnection db = new SqlConnection(Configuration.GetConnectionString("SampleDB")) | |
{ | |
string sqlQuery ="UPDATE Book SET Title = @Title, " + | |
"Author = @Author" + "WHERE Id = @Id"; | |
int rowsAffected = db.Execute(sqlQuery, author); | |
return rowsAffected; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<BookModel> GetBook(int id) | |
{ | |
using (IDbConnection db = new SqlConnection(Configuration.GetConnectionString("SampleDB")) | |
{ | |
var result= await db.Query<BookModel>("Select * From Book" + | |
WHERE Id = @Id", new { id }).SingleOrDefault(); | |
return result; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<BookModel> GetLatestBooks() | |
{ | |
using (IDbConnection db = new SqlConnection(Configuration.GetConnectionString("SampleDB")) | |
{ | |
return db.Query<BookModel> | |
("Select * From Book").ToList(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BookModel | |
{ | |
public int ID { get; set; } | |
public string Title { get; set; } | |
public string Author { get; set; } | |
public string Publisher { get; set; } | |
public string Category { get; set; } | |
public decimal Price { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Id": 226, | |
"Iso": "US", | |
"Name": "United States", | |
"Iso3": "USA", | |
"NumCode": 840, | |
"PhoneCode": 1, | |
"id": "ca025639-d776-4444-93dd-6739b0394ae9", | |
"_rid": "bRZNAO4ywesBAAAAAAAAAA==", | |
"_self": "dbs/bRZNAA==/colls/bRZNAO4ywes=/docs/bRZNAO4ywesBAAAAAAAAAA==/", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page | |
@model IndexModel | |
@{ | |
ViewData["Title"] = "Home page"; | |
} | |
<div class="parent-container d-flex"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleDBContext : DbContext | |
{ | |
public SampleDBContext(DbContextOptions<SampleDBContext> options) | |
: base(options) | |
{ | |
} | |
public DbSet<BookModel> BooksDbSet { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
// This method gets called by the runtime. Use this method to add services to the container. |