Skip to content

Commit a6abe3c

Browse files
committed
Mapping and some dtos changed
1 parent 63540b2 commit a6abe3c

File tree

16 files changed

+206
-1985
lines changed

16 files changed

+206
-1985
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using CmnSoftwareBackend.Entities.Dtos.CategoryAndArticleDtos;
6+
using CmnSoftwareBackend.Services.Abstract;
7+
using CmnSoftwareBackend.Shared.Utilities.Results.Concrete;
8+
using Microsoft.AspNetCore.Mvc;
9+
10+
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
11+
12+
namespace CmnSoftwareBackend.API.Controllers
13+
{
14+
[ProducesResponseType(200)]
15+
[ProducesResponseType(400)]
16+
[ProducesResponseType(500)]
17+
[ApiController]
18+
[Route("api/[controller]")]
19+
public class CategoryAndArticlesController : Controller
20+
{
21+
private readonly ICategoryAndArticleService _categoryAndArticleService;
22+
[HttpPost]
23+
[Route("[action]")]
24+
public async Task<IActionResult> AddAsync(CategoryAndArticleAddDto categoryAndArticleAddDto)
25+
{
26+
var result = await _categoryAndArticleService.AddAsync(categoryAndArticleAddDto);
27+
return Ok(new SuccessDataApiResult(result, Url.Link("", new { Controller = "CategoryAndArticles", Action = "Add" })));
28+
}
29+
30+
[HttpPost]
31+
[Route("[action]")]
32+
public async Task<IActionResult> HardDeleteAsync(CategoryAndArticlesUpdateDto categoryAndArticlesUpdateDto)
33+
{
34+
var result = await _categoryAndArticleService.HardDeleteAsync(categoryAndArticlesUpdateDto);
35+
return Ok(new SuccessDataApiResult(result, Url.Link("", new { Controller = "CategoryAndArticles", Action = "HardDelete" })));
36+
}
37+
38+
39+
}
40+
}
41+

src/v2/CmnSoftwareBackend.API/c:\temp\cmn-internal-nlog.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6425,3 +6425,59 @@ ClientConnectionId:00000000-0000-0000-0000-000000000000
64256425
2021-09-29 18:28:33.0378 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
64266426
2021-09-29 18:28:33.1284 Info Configuration initialized.
64276427
2021-09-29 18:28:33.1291 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False
6428+
2021-09-30 20:35:27.0587 Info Message Template Auto Format enabled
6429+
2021-09-30 20:35:27.0771 Info Loading assembly: NLog.Web.AspNetCore
6430+
2021-09-30 20:35:27.1159 Info Adding target FileTarget(Name=allfile)
6431+
2021-09-30 20:35:27.1173 Info Adding target FileTarget(Name=ownFile-web)
6432+
2021-09-30 20:35:27.1308 Info Adding target DatabaseTarget(Name=database)
6433+
2021-09-30 20:35:27.2159 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
6434+
2021-09-30 20:35:27.3137 Info Configuration initialized.
6435+
2021-09-30 20:35:27.3145 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False
6436+
2021-10-01 13:22:28.6327 Info Message Template Auto Format enabled
6437+
2021-10-01 13:22:28.6481 Info Loading assembly: NLog.Web.AspNetCore
6438+
2021-10-01 13:22:28.6866 Info Adding target FileTarget(Name=allfile)
6439+
2021-10-01 13:22:28.6879 Info Adding target FileTarget(Name=ownFile-web)
6440+
2021-10-01 13:22:28.6982 Info Adding target DatabaseTarget(Name=database)
6441+
2021-10-01 13:22:28.7787 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
6442+
2021-10-01 13:22:28.8740 Info Configuration initialized.
6443+
2021-10-01 13:22:28.8740 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False
6444+
2021-10-01 13:23:07.6759 Info Message Template Auto Format enabled
6445+
2021-10-01 13:23:07.6932 Info Loading assembly: NLog.Web.AspNetCore
6446+
2021-10-01 13:23:07.7315 Info Adding target FileTarget(Name=allfile)
6447+
2021-10-01 13:23:07.7334 Info Adding target FileTarget(Name=ownFile-web)
6448+
2021-10-01 13:23:07.7450 Info Adding target DatabaseTarget(Name=database)
6449+
2021-10-01 13:23:07.8410 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
6450+
2021-10-01 13:23:07.9231 Info Configuration initialized.
6451+
2021-10-01 13:23:07.9241 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False
6452+
2021-10-01 13:26:22.5097 Info Message Template Auto Format enabled
6453+
2021-10-01 13:26:22.5254 Info Loading assembly: NLog.Web.AspNetCore
6454+
2021-10-01 13:26:22.5615 Info Adding target FileTarget(Name=allfile)
6455+
2021-10-01 13:26:22.5629 Info Adding target FileTarget(Name=ownFile-web)
6456+
2021-10-01 13:26:22.5717 Info Adding target DatabaseTarget(Name=database)
6457+
2021-10-01 13:26:22.6491 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
6458+
2021-10-01 13:26:22.7359 Info Configuration initialized.
6459+
2021-10-01 13:26:22.7374 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False
6460+
2021-10-01 13:27:31.0413 Info Message Template Auto Format enabled
6461+
2021-10-01 13:27:31.0571 Info Loading assembly: NLog.Web.AspNetCore
6462+
2021-10-01 13:27:31.0924 Info Adding target FileTarget(Name=allfile)
6463+
2021-10-01 13:27:31.0936 Info Adding target FileTarget(Name=ownFile-web)
6464+
2021-10-01 13:27:31.1026 Info Adding target DatabaseTarget(Name=database)
6465+
2021-10-01 13:27:31.1830 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
6466+
2021-10-01 13:27:31.2723 Info Configuration initialized.
6467+
2021-10-01 13:27:31.2731 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False
6468+
2021-10-01 13:32:42.1839 Info Message Template Auto Format enabled
6469+
2021-10-01 13:32:42.2004 Info Loading assembly: NLog.Web.AspNetCore
6470+
2021-10-01 13:32:42.2357 Info Adding target FileTarget(Name=allfile)
6471+
2021-10-01 13:32:42.2370 Info Adding target FileTarget(Name=ownFile-web)
6472+
2021-10-01 13:32:42.2475 Info Adding target DatabaseTarget(Name=database)
6473+
2021-10-01 13:32:42.3444 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
6474+
2021-10-01 13:32:42.4294 Info Configuration initialized.
6475+
2021-10-01 13:32:42.4312 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False
6476+
2021-10-01 13:33:38.0371 Info Message Template Auto Format enabled
6477+
2021-10-01 13:33:38.0527 Info Loading assembly: NLog.Web.AspNetCore
6478+
2021-10-01 13:33:38.0898 Info Adding target FileTarget(Name=allfile)
6479+
2021-10-01 13:33:38.0909 Info Adding target FileTarget(Name=ownFile-web)
6480+
2021-10-01 13:33:38.1001 Info Adding target DatabaseTarget(Name=database)
6481+
2021-10-01 13:33:38.1796 Info Validating config: TargetNames=allfile, ownFile-web, database, ConfigItems=75, FilePath=/Users/yunus/Documents/GitHub/BlogApi-ASP.NET-Core/src/v2/CmnSoftwareBackend.API/bin/Debug/net5.0/NLog.config
6482+
2021-10-01 13:33:38.2719 Info Configuration initialized.
6483+
2021-10-01 13:33:38.2728 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.11.13229. Product version: 4.7.11+33ed3a9f86277651e93ddf39cda64a046a06778b. GlobalAssemblyCache: False

src/v2/CmnSoftwareBackend.Data/CmnSoftwareBackend.Data.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<None Remove="Concrete\" />
99
<None Remove="Concrete\EntityFramework\" />
1010
<None Remove="Concrete\EntityFramework\Contexts\" />
11-
<None Remove="Concrete\EntityFramework\Mappings\" />
1211
<None Remove="Microsoft.EntityFrameworkCore.Design" />
1312
<None Remove="Microsoft.EntityFrameworkCore.SqlServer" />
1413
<None Remove="Microsoft.EntityFrameworkCore" />
@@ -18,7 +17,6 @@
1817
<Folder Include="Concrete\" />
1918
<Folder Include="Concrete\EntityFramework\" />
2019
<Folder Include="Concrete\EntityFramework\Contexts\" />
21-
<Folder Include="Concrete\EntityFramework\Mappings\" />
2220
</ItemGroup>
2321
<ItemGroup>
2422
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.8">

src/v2/CmnSoftwareBackend.Data/Concrete/EntityFramework/Mappings/CategoryAndArticleMap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public class CategoryAndArticleMap:IEntityTypeConfiguration<CategoryAndArticle>
1111

1212
public void Configure(EntityTypeBuilder<CategoryAndArticle> builder)
1313
{
14-
builder.HasKey(ca => new { ca.CateogryId, ca.ArticleId });
14+
builder.HasKey(ca => new { ca.CategoryId, ca.ArticleId });
1515
//builder.Property(ca=>new {ca.CategoryId,ca.ArticleId }).ValueGeneratedOnAdd();
16-
builder.HasOne<Category>(ca => ca.Category).WithMany(c => c.CategoryAndArticles).HasForeignKey(ca=>ca.CateogryId);
16+
builder.HasOne<Category>(ca => ca.Category).WithMany(c => c.CategoryAndArticles).HasForeignKey(ca=>ca.CategoryId);
1717
builder.HasOne<Article>(ca => ca.Article).WithMany(c => c.CategoryAndArticles).HasForeignKey(ca => ca.ArticleId);
1818
builder.ToTable("CategoryAndArticles");
1919
}

src/v2/CmnSoftwareBackend.Data/Concrete/EntityFramework/Mappings/CategoryMap.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace CmnSoftwareBackend.Data.Concrete.EntityFramework.Mappings
77
{
8-
public class CategoryMap : IEntityTypeConfiguration<Category>
8+
public class CategoryMap:IEntityTypeConfiguration<Category>
99
{
10-
10+
1111
public void Configure(EntityTypeBuilder<Category> builder)
1212
{
1313
builder.HasKey(c => c.Id);
@@ -27,7 +27,7 @@ public void Configure(EntityTypeBuilder<Category> builder)
2727
builder.Property(c => c.IsDeleted).IsRequired();
2828
//wrong configure mapping
2929
//builder.HasOne<Article>(c => c.Article).WithMany(a => a.Categories).HasForeignKey(c => c.ArticleId);
30-
// builder.HasOne<Rank>(c => c.Rank).WithMany(r => r.Categories).HasForeignKey(c => c.RankId);
30+
builder.HasOne<Rank>(c => c.Rank).WithMany(r => r.Categories).HasForeignKey(c => c.RankId);
3131
builder.ToTable("Categories");
3232
}
3333
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using CmnSoftwareBackend.Entities.Concrete;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
5+
6+
namespace CmnSoftwareBackend.Data.Concrete.EntityFramework.Mappings
7+
{
8+
public class RankMap : IEntityTypeConfiguration<Rank>
9+
{
10+
public void Configure(EntityTypeBuilder<Rank> builder)
11+
{
12+
builder.HasKey(r => r.Id);
13+
builder.Property(a => a.Id).ValueGeneratedOnAdd();
14+
builder.ToTable("Ranks");
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)