-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
3,045 additions
and
134 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<packageSources> | ||
<!--To inherit the global NuGet package sources remove the <clear/> line below --> | ||
<clear /> | ||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> | ||
</packageSources> | ||
<disabledPackageSources> | ||
<clear /> | ||
</disabledPackageSources> | ||
<add key="nuget" value="https://api.nuget.org/v3/index.json" /> | ||
<add key="telerik" value="https://nuget.telerik.com/v3/index.json" /> | ||
</packageSources> | ||
<packageSourceCredentials> | ||
<telerik> | ||
<add key="Username" value="your telerik account email" /> | ||
<add key="ClearTextPassword" value="your plain text password" /> | ||
</telerik> | ||
</packageSourceCredentials> | ||
</configuration> |
67 changes: 67 additions & 0 deletions
67
examples-standalone/aspnetcore-data/Server/Controllers/BlogsController.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System.Linq; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Kendo.Mvc.UI; | ||
using Kendo.Mvc.Extensions; | ||
using Server.Models; | ||
|
||
namespace Server.Controllers | ||
{ | ||
public class BlogsController : Controller | ||
{ | ||
private readonly BloggingContext _context; | ||
|
||
public BlogsController(BloggingContext context) | ||
{ | ||
|
||
_context = context; | ||
} | ||
|
||
[Route("api/Blogs")] | ||
[HttpGet] | ||
public JsonResult GetProducts([DataSourceRequest] DataSourceRequest request) | ||
{ | ||
var result = Json(this._context.Blog.ToList().ToDataSourceResult(request)); | ||
return result; | ||
} | ||
|
||
[Route("api/Blogs")] | ||
[HttpPost] | ||
public JsonResult AddBlog([FromBody] Blog request) | ||
{ | ||
|
||
this._context.Add(request); | ||
this._context.SaveChanges(); | ||
var result = Json(this._context.Blog.Local); | ||
return result; | ||
|
||
} | ||
|
||
[Route("api/Blogs/{id}")] | ||
[HttpDelete] | ||
public JsonResult DeleteBlog([FromBody] Blog request) | ||
{ | ||
this._context.Remove(request); | ||
this._context.SaveChanges(); | ||
var result = Json(this._context.Blog.Local); | ||
return result; | ||
} | ||
|
||
[Route("api/Blogs/{id}")] | ||
[HttpPut] | ||
|
||
public JsonResult Editblog([FromBody] Blog request) | ||
{ | ||
|
||
var existingblog = this._context.Blog.Where(b => b.BlogId == request.BlogId).FirstOrDefault<Blog>(); | ||
|
||
if (existingblog != null) | ||
{ | ||
existingblog.Url = request.Url; | ||
} | ||
this._context.SaveChanges(); | ||
|
||
var result = Json(this._context.Blog.Local); | ||
return result; | ||
} | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
examples-standalone/aspnetcore-data/Server/Controllers/WeatherForecastController.cs
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Server.Models | ||
{ | ||
public partial class Blog | ||
{ | ||
public Blog() | ||
{ | ||
Post = new HashSet<Post>(); | ||
} | ||
|
||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
|
||
public virtual ICollection<Post> Post { get; set; } | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
examples-standalone/aspnetcore-data/Server/Model/BloggingContext.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using System.Collections.Generic; | ||
using System.Reflection.Emit; | ||
|
||
namespace Server.Models | ||
{ | ||
public partial class BloggingContext : DbContext | ||
{ | ||
public BloggingContext() | ||
{ | ||
} | ||
|
||
public BloggingContext(DbContextOptions<BloggingContext> options) | ||
: base(options) | ||
{ | ||
} | ||
|
||
public virtual DbSet<Blog> Blog { get; set; } | ||
public virtual DbSet<Post> Post { get; set; } | ||
|
||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||
{ | ||
if (!optionsBuilder.IsConfigured) | ||
{ | ||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings. | ||
optionsBuilder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=Blogging;Trusted_Connection=True;"); | ||
} | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Blog>(entity => | ||
{ | ||
entity.Property(e => e.Url).IsRequired(); | ||
}); | ||
|
||
modelBuilder.Entity<Post>(entity => | ||
{ | ||
entity.HasOne(d => d.Blog) | ||
.WithMany(p => p.Post) | ||
.HasForeignKey(d => d.BlogId); | ||
}); | ||
OnModelCreatingPartial(modelBuilder); | ||
} | ||
|
||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Server.Models | ||
{ | ||
public partial class Post | ||
{ | ||
public int PostId { get; set; } | ||
public int BlogId { get; set; } | ||
public string Content { get; set; } | ||
public string Title { get; set; } | ||
|
||
public virtual Blog Blog { get; set; } | ||
} | ||
} |
32 changes: 5 additions & 27 deletions
32
examples-standalone/aspnetcore-data/Server/Properties/launchSettings.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,12 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:45002", | ||
"sslPort": 0 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"aspnetcore-data": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"applicationUrl": "http://localhost:5263", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" | ||
} | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "https://localhost:57983;http://localhost:57984" | ||
} | ||
} | ||
} | ||
|
||
} |
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
7 changes: 7 additions & 0 deletions
7
examples-standalone/aspnetcore-data/Server/Server.csproj.user
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID> | ||
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath> | ||
</PropertyGroup> | ||
</Project> |
13 changes: 0 additions & 13 deletions
13
examples-standalone/aspnetcore-data/Server/WeatherForecast.cs
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.