Skip to content

Instantly share code, notes, and snippets.

public class BPJSRegisterationViewModel
{
public string NoBPJS { get; set; }
public string NamaPeserta { get; set; }
public string ValidFrom { get; set; }
}
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
namespace belajarnetcoremvc.Models
{
public class belajarDbContext :DbContext
{
public belajarDbContext(DbContextOptions options) : base(options)
{
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using belajarnetcoremvc.Models;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
{
"ConnectionStrings":{
"DefaultConnection" :"server=.\\sqlexpress; database=belajarDb;user id=sa;password=[password]"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
public class HomeController : Controller
{
[Authorize]
public IActionResult Index()
{
var roles = User.Identities;
return View(roles);
}
[Authorize(Roles="Penulis")]
public IActionResult About()
@gsedubun
gsedubun / Program.cs
Last active March 1, 2018 11:09
Demo implementation of IComparable<T>
class Program
{
private static WorkDay workday1 = new WorkDay { Day = 1, DayName = "Monday" };
private static WorkDay workday2 = new WorkDay { Day = 2, DayName = "Tuesday" };
private static WorkDay workday3 = new WorkDay { Day = 3, DayName = "Wednesday" };
private static WorkDay workday4 = new WorkDay { Day = 4, DayName = "Thursday" };
private static WorkDay workday5 = new WorkDay { Day = 5, DayName = "Friday" };
private static Shift shift1 = new Shift { Start = TimeSpan.Parse("08:00"), End = TimeSpan.Parse("12:00"), Name = "Shift 1" };
private static Shift shift2 = new Shift { Start = TimeSpan.Parse("12:00"), End = TimeSpan.Parse("16:00"), Name = "Shift 2" };
private static Shift shift3 = new Shift { Start = TimeSpan.Parse("16:00"), End = TimeSpan.Parse("20:00"), Name = "Shift 3" };
@gsedubun
gsedubun / todoangular.TodoRepository.cs
Last active April 2, 2018 02:12
dbcontext untuk asp.net core inmemory Db provider
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace TodoNetCoreAngular.Models
{
public class TodoRepository
{
private readonly TodoDbContext context;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.SpaServices.Webpack;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using TodoNetCoreAngular.Models;
namespace TodoNetCoreAngular.Controllers
{
[Route("api/[controller]")]
public class TodoController : Controller
{
<h1>Todo </h1>
<p>This component is to run todo app.</p>
<p *ngIf="!todos"><em>Loading...</em></p>
<div class="col-md-3 input-group">
<!-- <label>New todo
</label> -->
<input [(ngModel)]="todo.title" class="form-control" placeholder="New todo title.">
<span class="input-group-btn">