Skip to content

Commit

Permalink
update server
Browse files Browse the repository at this point in the history
  • Loading branch information
mbechev committed Mar 5, 2024
1 parent f6df04d commit 4d07c74
Show file tree
Hide file tree
Showing 15 changed files with 3,045 additions and 134 deletions.
17 changes: 11 additions & 6 deletions examples-standalone/aspnetcore-data/Client/nuget.config
@@ -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>
@@ -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;
}
}
}

This file was deleted.

15 changes: 15 additions & 0 deletions examples-standalone/aspnetcore-data/Server/Model/Blog.cs
@@ -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; }
}
}
@@ -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);
}
}
12 changes: 12 additions & 0 deletions examples-standalone/aspnetcore-data/Server/Model/Post.cs
@@ -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; }
}
}
@@ -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"
}
}
}

}
3 changes: 3 additions & 0 deletions examples-standalone/aspnetcore-data/Server/Server.csproj
Expand Up @@ -14,7 +14,10 @@
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
<Version>8.*-*</Version>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Telerik.UI.for.AspNet.Core.Trial" Version="2023.3.1114" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions examples-standalone/aspnetcore-data/Server/Server.csproj.user
@@ -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 examples-standalone/aspnetcore-data/Server/WeatherForecast.cs

This file was deleted.

Expand Up @@ -47,9 +47,21 @@
"target": "Package",
"version": "[8.*-*, )"
},
"Microsoft.EntityFrameworkCore": {
"target": "Package",
"version": "[8.0.2, )"
},
"Microsoft.EntityFrameworkCore.SqlServer": {
"target": "Package",
"version": "[8.0.2, )"
},
"Swashbuckle.AspNetCore": {
"target": "Package",
"version": "[6.4.0, )"
},
"Telerik.UI.for.AspNet.Core.Trial": {
"target": "Package",
"version": "[2023.3.1114, )"
}
},
"imports": [
Expand Down
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">False</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/bechev/.nuget/packages/</NuGetPackageRoot>
Expand All @@ -15,6 +15,7 @@
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.extensions.apidescription.server/6.0.5/build/Microsoft.Extensions.ApiDescription.Server.props" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.apidescription.server/6.0.5/build/Microsoft.Extensions.ApiDescription.Server.props')" />
<Import Project="$(NuGetPackageRoot)swashbuckle.aspnetcore/6.4.0/build/Swashbuckle.AspNetCore.props" Condition="Exists('$(NuGetPackageRoot)swashbuckle.aspnetcore/6.4.0/build/Swashbuckle.AspNetCore.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.entityframeworkcore/8.0.2/buildTransitive/net8.0/Microsoft.EntityFrameworkCore.props" Condition="Exists('$(NuGetPackageRoot)microsoft.entityframeworkcore/8.0.2/buildTransitive/net8.0/Microsoft.EntityFrameworkCore.props')" />
</ImportGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgMicrosoft_Extensions_ApiDescription_Server Condition=" '$(PkgMicrosoft_Extensions_ApiDescription_Server)' == '' ">/Users/bechev/.nuget/packages/microsoft.extensions.apidescription.server/6.0.5</PkgMicrosoft_Extensions_ApiDescription_Server>
Expand Down
Expand Up @@ -2,6 +2,8 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.extensions.apidescription.server/6.0.5/build/Microsoft.Extensions.ApiDescription.Server.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.apidescription.server/6.0.5/build/Microsoft.Extensions.ApiDescription.Server.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.options/8.0.0/buildTransitive/net6.0/Microsoft.Extensions.Options.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.options/8.0.0/buildTransitive/net6.0/Microsoft.Extensions.Options.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.extensions.logging.abstractions/8.0.0/buildTransitive/net6.0/Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.logging.abstractions/8.0.0/buildTransitive/net6.0/Microsoft.Extensions.Logging.Abstractions.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.spaproxy/8.0.2/build/Microsoft.AspNetCore.SpaProxy.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.spaproxy/8.0.2/build/Microsoft.AspNetCore.SpaProxy.targets')" />
</ImportGroup>
</Project>

0 comments on commit 4d07c74

Please sign in to comment.