31
Getting Started with .NET on OpenSuse (ASP.NET with C#) Alin Nur Alifah / Alin [email protected]

Getting started with .net on openSUSE (asp.net with c#)

Embed Size (px)

Citation preview

Page 1: Getting started with .net on openSUSE  (asp.net with c#)

Getting Started with .NET on OpenSuse

(ASP.NET with C#)

Alin Nur Alifah / [email protected]

Page 2: Getting started with .net on openSUSE  (asp.net with c#)

Alin Nur Alifah

Alinalinnural.com

@alinnural

Page 3: Getting started with .net on openSUSE  (asp.net with c#)

GNU Linux Bogor Activist

WEB Developer @IPB

Ilkomerz @IPB

Page 4: Getting started with .net on openSUSE  (asp.net with c#)

Thank you

Page 5: Getting started with .net on openSUSE  (asp.net with c#)

Thank youFor join my class

Page 6: Getting started with .net on openSUSE  (asp.net with c#)

Lets sharing...

Page 7: Getting started with .net on openSUSE  (asp.net with c#)

.NET ???

Page 8: Getting started with .net on openSUSE  (asp.net with c#)

.NET ???.NET is a layer of software that makes it easier for you to write

programs

Page 9: Getting started with .net on openSUSE  (asp.net with c#)

.NET Core Vs

.NET Framework

Page 10: Getting started with .net on openSUSE  (asp.net with c#)

.NET Core Vs

.NET Framework

.NET Core is a general purpose, modular, cross-platform and open source implementation of the .NET Platform.

Page 11: Getting started with .net on openSUSE  (asp.net with c#)

.NET with C# Languange

Page 12: Getting started with .net on openSUSE  (asp.net with c#)

C# LanguangeThe C# language is disarmingly simple, which makes it good for beginners, but

C# also includes all the support for the structured, component-based, object-oriented programming that one expects of a modern language built on

the shoulders of C++ and Java.

Page 13: Getting started with .net on openSUSE  (asp.net with c#)

Lets Code...

Page 14: Getting started with .net on openSUSE  (asp.net with c#)

Install dotnet

# sudo zypper install libunwind libicu

# curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=827532

# sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet

# sudo ln -s /opt/dotnet/dotnet /usr/local/bin

Page 15: Getting started with .net on openSUSE  (asp.net with c#)

Let's initialize a sample Hello World application!

# mkdir hwapp

# cd hwapp

# dotnet new

# dotnet restore

# dotnet run

Page 16: Getting started with .net on openSUSE  (asp.net with c#)

Let's initialize a sample Hello World application!

Page 17: Getting started with .net on openSUSE  (asp.net with c#)

Simple ASP.NET Core Application

Page 18: Getting started with .net on openSUSE  (asp.net with c#)

Node.js and npm is required !

Page 19: Getting started with .net on openSUSE  (asp.net with c#)

Install node.js and npm

# wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | bash

# source ~/.bashrc

# nvm install v.x.xx.x

Page 20: Getting started with .net on openSUSE  (asp.net with c#)

Scaffolding usings Yeoman

Install the necessary yeoman generators and bower using npm.

# npm install -g yo generator-aspnet bower

Run the ASP.NET Core generator

# yo aspnet

# dotnet restore# dotnet run

Page 21: Getting started with .net on openSUSE  (asp.net with c#)

Scaffolding usings Yeoman

Page 22: Getting started with .net on openSUSE  (asp.net with c#)

Scaffolding usings Yeoman

Page 23: Getting started with .net on openSUSE  (asp.net with c#)

Sub Generators

https://github.com/omnisharp/generator-aspnet#sub-generators

eg : add a new class # yo aspnet:mvccontroller BlogController

Page 24: Getting started with .net on openSUSE  (asp.net with c#)

Connect DatabaseNew SQLite Database

"dependencies": { "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0", "Microsoft.EntityFrameworkCore.Design": { "version": "1.0.0-preview2-final", "type": "build" }

"tools": { "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" }

Page 25: Getting started with .net on openSUSE  (asp.net with c#)

Connect Database

Verify that Entity Framework is installed by running

# dotnet ef - -help

Run dotnet restore again to install the new packages.

# dotnet restore

Page 26: Getting started with .net on openSUSE  (asp.net with c#)

Create Model

Page 27: Getting started with .net on openSUSE  (asp.net with c#)

Generate Database

This will find our context and models, and generate a migration

# dotnet ef migrations add MyFirstMigration

create the database file and creates the tables

# dotnet ef database update

Page 28: Getting started with .net on openSUSE  (asp.net with c#)

Use Model on Controller

[HttpGet] [AllowAnonymous] public IActionResult Index(string nama = null) { var db = new BloggingContext(); db.Blogs.Add(new Blog { Url = nama }); db.SaveChanges();

ViewData["daftarBlog"] = db.Blogs; return View(); }

Page 29: Getting started with .net on openSUSE  (asp.net with c#)
Page 30: Getting started with .net on openSUSE  (asp.net with c#)

Thank you

Page 31: Getting started with .net on openSUSE  (asp.net with c#)

Referensihttps://docs.asp.net/en/latest/tutorials/your-first-mac-aspnet.html

https://docs.asp.net/en/latest/client-side/yeoman.htmlhttps://github.com/omnisharp/generator-aspnet#sub-generators