Skip to content

Instantly share code, notes, and snippets.

View BPJS.cs
public class BPJSRegisterationViewModel
{
public string NoBPJS { get; set; }
public string NamaPeserta { get; set; }
public string ValidFrom { get; set; }
}
View belajarDbContext.cs
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
namespace belajarnetcoremvc.Models
{
public class belajarDbContext :DbContext
{
public belajarDbContext(DbContextOptions options) : base(options)
{
}
View belajarStartup.cs
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;
View belajaraspnetcore.appsettings.json
{
"ConnectionStrings":{
"DefaultConnection" :"server=.\\sqlexpress; database=belajarDb;user id=sa;password=[password]"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
View belajaraspnetcorehomecontroller.cs
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 Mar 1, 2018
Demo implementation of IComparable<T>
View Program.cs
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 Apr 2, 2018
dbcontext untuk asp.net core inmemory Db provider
View todoangular.TodoRepository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace TodoNetCoreAngular.Models
{
public class TodoRepository
{
private readonly TodoDbContext context;
View todoangular.startup.cs
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;
View todoangular.todocontroller.cs
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using TodoNetCoreAngular.Models;
namespace TodoNetCoreAngular.Controllers
{
[Route("api/[controller]")]
public class TodoController : Controller
{
View todoangular.app.shared.module.ts
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { FormsModule } from "@angular/forms";
import { HttpModule } from "@angular/http";
import { RouterModule } from "@angular/router";
import {Location } from "@angular/common";
import { AppComponent } from "./components/app/app.component";
import { NavMenuComponent } from "./components/navmenu/navmenu.component";
import { HomeComponent } from "./components/home/home.component";
import { FetchDataComponent } from "./components/fetchdata/fetchdata.component";