Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
TechBrij committed Aug 28, 2016
0 parents commit bcef09d
Show file tree
Hide file tree
Showing 73 changed files with 34,583 additions and 0 deletions.
32 changes: 32 additions & 0 deletions ASPCoreSample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9D6EBCBD-3AEF-4027-9E1E-F3633F998AE4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EC2BED90-51D7-48BC-8B2D-DB604CE6CCFC}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ASPCoreSample", "src\ASPCoreSample\ASPCoreSample.xproj", "{67948CC9-95A5-4618-8375-2649CBD9A228}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{67948CC9-95A5-4618-8375-2649CBD9A228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67948CC9-95A5-4618-8375-2649CBD9A228}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67948CC9-95A5-4618-8375-2649CBD9A228}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67948CC9-95A5-4618-8375-2649CBD9A228}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{67948CC9-95A5-4618-8375-2649CBD9A228} = {9D6EBCBD-3AEF-4027-9E1E-F3633F998AE4}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
3 changes: 3 additions & 0 deletions src/ASPCoreSample/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "wwwroot/lib"
}
23 changes: 23 additions & 0 deletions src/ASPCoreSample/ASPCoreSample.xproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>67948cc9-95a5-4618-8375-2649cbd9a228</ProjectGuid>
<RootNamespace>ASPCoreSample</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<DnxInvisibleContent Include="bower.json" />
<DnxInvisibleContent Include=".bowerrc" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
6 changes: 6 additions & 0 deletions src/ASPCoreSample/ASPCoreSample.xproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
</PropertyGroup>
</Project>
82 changes: 82 additions & 0 deletions src/ASPCoreSample/Controllers/CustomerController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using ASPCoreSample.Models;
using ASPCoreSample.Repository;

namespace ASPCoreSample.Controllers
{
public class CustomerController : Controller
{
private readonly CustomerRepository customerRepository;

public CustomerController(IConfiguration configuration)
{
customerRepository = new CustomerRepository(configuration);
}


public IActionResult Index()
{
return View(customerRepository.FindAll());
}

public IActionResult Create()
{
return View();
}

// POST: Customer/Create
[HttpPost]
public IActionResult Create(Customer cust)
{
if (ModelState.IsValid)
{
customerRepository.Add(cust);
return RedirectToAction("Index");
}
return View(cust);

}

// GET: /Customer/Edit/1
public IActionResult Edit(int? id)
{
if (id == null)
{
return NotFound();
}
Customer obj = customerRepository.FindByID(id.Value);
if (obj == null)
{
return NotFound();
}
return View(obj);

}

// POST: /Customer/Edit
[HttpPost]
public IActionResult Edit(Customer obj)
{

if (ModelState.IsValid)
{
customerRepository.Update(obj);
return RedirectToAction("Index");
}
return View(obj);
}

// GET:/Customer/Delete/1
public IActionResult Delete(int? id)
{

if (id == null)
{
return NotFound();
}
customerRepository.Remove(id.Value);
return RedirectToAction("Index");
}
}
}
35 changes: 35 additions & 0 deletions src/ASPCoreSample/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace ASPCoreSample.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}

public IActionResult About()
{
ViewData["Message"] = "Your application description page.";

return View();
}

public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";

return View();
}

public IActionResult Error()
{
return View();
}
}
}
11 changes: 11 additions & 0 deletions src/ASPCoreSample/Models/BaseEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ASPCoreSample.Models
{
public abstract class BaseEntity
{
}
}
27 changes: 27 additions & 0 deletions src/ASPCoreSample/Models/Customer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using System.ComponentModel.DataAnnotations;

namespace ASPCoreSample.Models
{
public class Customer : BaseEntity
{
[Key]
public long Id { get; set; }

[Required]
public string Name { get; set; }

[Required]
public string Email { get; set; }

[Required]
public string Phone { get; set; }


public string Address { get; set; }
}
}
24 changes: 24 additions & 0 deletions src/ASPCoreSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;

namespace ASPCoreSample
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();

host.Run();
}
}
}
Loading

0 comments on commit bcef09d

Please sign in to comment.