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
using System.ComponentModel.DataAnnotations; | |
namespace CockroachDbLib.Models | |
{ | |
public class Account | |
{ | |
[Key] | |
public int id { get; set; } | |
public int balance { 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
using Microsoft.EntityFrameworkCore; | |
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace CockroachDbLib.Models | |
{ | |
public class CockroachDbContext : DbContext | |
{ | |
public CockroachDbContext(DbContextOptions<CockroachDbContext> options) : base(options) |
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
using CockroachDbLib.Models; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
namespace CockroachDbLib.Repository | |
{ | |
public interface IAccountRepository | |
{ | |
List<Account> GetAllAccounts(); |
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
using CockroachDbLib.Models; | |
using Microsoft.EntityFrameworkCore; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace CockroachDbLib.Repository | |
{ | |
public class AccountRepository : IAccountRepository | |
{ |
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
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using CockroachDbLib.Models; | |
using CockroachDbLib.Repository; | |
using Microsoft.AspNetCore.Mvc; | |
namespace BlazorAppWithCockroachDB.Api.Controllers | |
{ | |
[Route("api/[controller]")] | |
[ApiController] |
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
namespace BlazorAppWithCockroachDB.Model | |
{ | |
public class Account | |
{ | |
public int id { get; set; } | |
public int balance { get; set; } | |
public string name { 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
using System; | |
using System.ComponentModel.DataAnnotations; | |
namespace BlazorAppWithCockroachDB.Model | |
{ | |
public class AccountModel | |
{ | |
[Required(ErrorMessage = "Balance is required")] | |
[Range(minimum: 1, 99999999, ErrorMessage = "Minimum allowed balance is $1")] | |
public int balance { 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
@page "/Accounts" | |
@using BlazorAppWithCockroachDB.Model; | |
@inject HttpClient Http | |
@inject NavigationManager NavigationManager | |
@inject IJSRuntime js | |
<h3>All Accounts</h3> |
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 "/CreateAccount" | |
@using BlazorAppWithCockroachDB.Model; | |
@using Newtonsoft.Json | |
@inject NavigationManager NavigationManager | |
@inject HttpClient Http | |
<h3>Create an Account</h3> |
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 "/EditAccount/{Id:int}" | |
@using BlazorAppWithCockroachDB.Model; | |
@using Newtonsoft.Json | |
@inject NavigationManager NavigationManager | |
@inject HttpClient Http | |
<h3>Edit Account</h3> |
OlderNewer