Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
86cd029
Add exception tests case for Delete by Id in comments service tests
lakatoshv Nov 2, 2025
8c3e2c4
Add exception tests case for Delete by Object in comments service tests
lakatoshv Nov 2, 2025
5c93e71
Add exception tests case for Delete Enumerable in comments service tests
lakatoshv Nov 3, 2025
deb5e64
Add exception tests case for Delete Async by Id in comments service t…
lakatoshv Nov 3, 2025
8e978c3
Add exception tests case for Delete Async by Object in comments servi…
lakatoshv Nov 3, 2025
289636e
Add exception tests case for Delete Async Enumerable in comments serv…
lakatoshv Nov 3, 2025
f8749bd
Add exception tests case for Delete by Id in messages service tests
lakatoshv Nov 4, 2025
74337a5
Add exception tests case for Delete by Object in messages service tests
lakatoshv Nov 4, 2025
9f5f1f2
Add exception tests case for Delete Enumerable in messages service tests
lakatoshv Nov 4, 2025
c479d0b
Add exception tests case for Delete Async by Id in messages service t…
lakatoshv Nov 4, 2025
8038468
Add exception tests case for Delete Async by Object in messages servi…
lakatoshv Nov 5, 2025
bb173a7
Add exception tests case for Delete Async Enumerable in messages serv…
lakatoshv Nov 5, 2025
156ef55
Fix posts unit tests
lakatoshv Nov 5, 2025
e0984f4
Add exception tests case for Delete by object in posts service tests
lakatoshv Nov 5, 2025
413be5a
Add exception tests case for Delete by Id in posts service tests
lakatoshv Nov 6, 2025
17b6093
Add exception tests case for Delete by Enumerable in posts service tests
lakatoshv Nov 6, 2025
e42bf0a
Add exception tests case for Delete Async by Id in posts service tests
lakatoshv Nov 6, 2025
acb3373
Add exception tests case for Delete Async by Object in posts service …
lakatoshv Nov 6, 2025
228a95f
Add exception tests case for Delete Async by Enumerable in posts serv…
lakatoshv Nov 7, 2025
b7ccded
Add exception tests case for Delete by Id in post tag relations servi…
lakatoshv Nov 7, 2025
79a958f
Add exception tests case for Delete by Object in post tag relations s…
lakatoshv Nov 7, 2025
0f4fa57
Add exception tests case for Delete by Enumerable in post tag relatio…
lakatoshv Nov 7, 2025
00f9bd3
Add exception tests case for Delete async by id in post tag relations…
lakatoshv Nov 8, 2025
8470c04
Add exception tests case for Delete Async by Object in post tag relat…
lakatoshv Nov 8, 2025
b356c9f
Add exception tests case for Delete Async by Enumerable in post tag r…
lakatoshv Nov 8, 2025
b99309d
Fix unit tests in Profile service tests
lakatoshv Nov 8, 2025
540296a
Add exception tests case for Delete by Id in profile service tests
lakatoshv Nov 9, 2025
177ecb1
Add exception tests case for Delete by Object in profile service tests
lakatoshv Nov 9, 2025
e4e737f
Add exception tests case for Delete by Enumeable in profile service t…
lakatoshv Nov 9, 2025
b7c0ae3
Add exception tests case for Delete Async by Id in profile service tests
lakatoshv Nov 9, 2025
cf5292c
Add exception tests case for Delete Async by Object in profile servic…
lakatoshv Nov 10, 2025
091e696
Add exception tests case for Delete Async by Enumerable in profile se…
lakatoshv Nov 10, 2025
2fee195
Add exception tests case for Delete by Id in tags service tests
lakatoshv Nov 10, 2025
f663802
Add exception tests case for Delete by Object in tags service tests
lakatoshv Nov 10, 2025
af828f4
Add exception tests case for Delete by Enumerable in tags service tests
lakatoshv Nov 11, 2025
72984d8
Add exception tests case for Delete Async by Id in tags service tests
lakatoshv Nov 11, 2025
007fa73
Add exception tests case for Delete Async by Object in tags service t…
lakatoshv Nov 11, 2025
061c984
Add exception tests case for Delete Async by Enumerable in tags servi…
lakatoshv Nov 11, 2025
e1eb482
Code refactoring in Blog.Core
lakatoshv Dec 1, 2025
c8b18df
Code refactoring in Blog.Contracts
lakatoshv Dec 1, 2025
e3caacb
Code refactoring in Blog,Data.Core
lakatoshv Dec 2, 2025
232ffaf
Code refactoring in Blog.Data.Models
lakatoshv Dec 2, 2025
c8397fc
Fix typo in Repository SearchBySequenceAsync method name
lakatoshv Dec 2, 2025
3fc851f
Code refactoring in Blog.Data
lakatoshv Dec 2, 2025
de04edc
Code refactoring in Blog.Services.Core
lakatoshv Dec 2, 2025
a8ea698
Code refactoring in Blog.CommonServices
lakatoshv Dec 2, 2025
bf25aa7
Code refactoring in Blog.Services
lakatoshv Dec 2, 2025
d874dae
Code refactoring in Blog.Web
lakatoshv Dec 3, 2025
916f0dc
Code refactoring in Blog.ServicesTests
lakatoshv Dec 4, 2025
0aacbfc
Code refactoring in Blog.Sdk
lakatoshv Dec 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@
/BlogWebApp/Blog.Web/ClientApp/.angular/cache/20.0.1/BlogAngular
/BlogWebApp/Blog.Web/ClientApp/dist/BlogAngular
/Clients/BlogRazor/bin/Debug/net9.0
/BlogWebApp/BlogBlazor/bin/Debug/net9.0
/BlogWebApp/BlogBlazor/obj
4 changes: 2 additions & 2 deletions BlogWebApp/Blog.Web/Cache/CachedAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
/// <remarks>
/// Initializes a new instance of the <see cref="CachedAttribute"/> class.
/// </remarks>
/// <param name="lifeTimeSeconds">The life time seconds.</param>
/// <param name="lifeTimeSeconds">The lifetime seconds.</param>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class CachedAttribute(int lifeTimeSeconds)
: Attribute, IAsyncActionFilter
{
/// <summary>
/// The life time seconds.
/// The lifetime seconds.
/// </summary>
private readonly int _lifeTimeSeconds = lifeTimeSeconds;

Expand Down
2 changes: 1 addition & 1 deletion BlogWebApp/Blog.Web/Controllers/V1/AccountsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public async Task<IActionResult> CreateAsync([FromBody] RegistrationRequest mode
return Bad(result);
}

model.Roles ??= new[] {"User"};
model.Roles ??= ["User"];

foreach(var role in model.Roles)
{
Expand Down
2 changes: 1 addition & 1 deletion BlogWebApp/Blog.Web/Controllers/V1/CommentsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public async Task<IActionResult> CreateAsync([FromBody] CreateCommentRequest req
comment.CreatedAt = Now;
await _commentService.InsertAsync(comment);
var response = new CreatedResponse<int> {Id = comment.Id};
var baseUrl = $@"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
var locationUrl = baseUrl + "/" +
ApiRoutes.CommentsController.Comments + "/" +
ApiRoutes.CommentsController.GetComment + "/" + comment.Id;
Expand Down
2 changes: 1 addition & 1 deletion BlogWebApp/Blog.Web/Controllers/V1/PostsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public async Task<IActionResult> CreateAsync([FromBody] CreatePostRequest model)

var response = new CreatedResponse<int> { Id = postToCreate.Id };

var baseUrl = $@"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
var locationUrl = baseUrl + "/" + ApiRoutes.PostsController.Show.Replace("{id}", postToCreate.Id.ToString());

return Created(locationUrl, response);
Expand Down
12 changes: 5 additions & 7 deletions BlogWebApp/Blog.Web/Controllers/V1/TagsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public async Task<ActionResult> GetTags()
[Cached(600)]
public async Task<ActionResult> GetTagsByFilter([FromBody] SearchParametersRequest searchParameters = null)
{
if (searchParameters == null)
return BadRequest();

searchParameters.SortParameters ??= new SortParametersRequest();

searchParameters.SortParameters.OrderBy ??= "asc";
Expand Down Expand Up @@ -179,12 +182,7 @@ public async Task<ActionResult> TagsActivity()
[Authorize]
public async Task<IActionResult> CreateAsync([FromBody] CreateTagRequest model)
{
if (!ModelState.IsValid)
{
return Bad(ModelState);
}

if (await _tagsService.AnyAsync(new TagSpecification(x => x.Title.ToLower().Equals(model.Title.ToLower()))))
if (!ModelState.IsValid || await _tagsService.AnyAsync(new TagSpecification(x => x.Title.ToLower().Equals(model.Title.ToLower()))))
{
return Bad(ModelState);
}
Expand All @@ -194,7 +192,7 @@ public async Task<IActionResult> CreateAsync([FromBody] CreateTagRequest model)

var response = new CreatedResponse<int> { Id = tag.Id };

var baseUrl = $@"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
var locationUrl = baseUrl + "/" + ApiRoutes.TagsController.GetTag.Replace("{id}", tag.Id.ToString());

return Created(locationUrl, response);
Expand Down
2 changes: 1 addition & 1 deletion BlogWebApp/Blog.Web/Factories/CategoryRequestFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override CreateCategoryRequest GenerateForCreate() =>
public override UpdateCategoryRequest GenerateForUpdate(int id)
{
var category = _unitOfWork.GetRepository<Category>().FirstOrDefault(new CategorySpecification(x => x.Id == id))
?? throw new MicroserviceArgumentNullException();;
?? throw new MicroserviceArgumentNullException();


var mapped = _mapper.Map<UpdateCategoryRequest>(category);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
}

/// <summary>
/// Lowercase the everything but parameters.
/// Lowercase everything but parameters.
/// </summary>
/// <param name="key">The key.</param>
/// <returns>string.</returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context)
if (attributes.Any())
{
var groupNameAttribute = attributes.First();
operation.Tags = new[] { new OpenApiTag { Name = groupNameAttribute.GroupName } };
operation.Tags = [new OpenApiTag { Name = groupNameAttribute.GroupName }];
}
else
{
operation.Tags = new[] { new OpenApiTag { Name = controllerActionDescriptor.RouteValues["controller"] } };
operation.Tags = [new OpenApiTag { Name = controllerActionDescriptor.RouteValues["controller"] }];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ public void InstallServices(IServiceCollection services, IConfiguration configur
});
services.AddCors(options =>
{
options.AddPolicy("AllowAll", bilder =>
options.AddPolicy("AllowAll", builder =>
{
bilder.AllowAnyOrigin()
builder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
options.AddPolicy("AllowAllBlazor", bilder =>
options.AddPolicy("AllowAllBlazor", builder =>
{
bilder.WithOrigins("https://localhost:44390").AllowAnyOrigin()
builder.WithOrigins("https://localhost:44390").AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void InstallServices(IServiceCollection services, IConfiguration configur
{
builder.AllowAnyHeader();
builder.AllowAnyMethod();
builder.SetIsOriginAllowed(host => true);
builder.SetIsOriginAllowed(_ => true);
builder.AllowCredentials();
}
else
Expand Down
2 changes: 1 addition & 1 deletion BlogWebApp/Blog.Web/StartupConfigures/ConfigureSpa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)

if (env.IsDevelopment())
{
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200"); ;
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
/// <summary>
/// Created response example.
/// </summary>
/// <seealso cref="IExamplesProvider{CreatedResponse{int}}" />
/// <seealso>
/// <cref>IExamplesProvider{CreatedResponse{int}}</cref>
/// </seealso>
public class CreatedResponseExample : IExamplesProvider<CreatedResponse<int>>
{
/// <inheritdoc cref="IExamplesProvider{T}"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace BLog.Web.ViewModels.AspNetUser;

/// <summary>
/// Two factor authentication view model
/// Two-factor authentication view model
/// </summary>
public class TwoFactorAuthenticationViewModel
{
Expand Down
3 changes: 3 additions & 0 deletions BlogWebApp/Blog.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="C:\Users\user\.nuget\packages\microsoft.aspnetcore.mvc.core\2.2.5\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=780df159_002D8db1_002D4d42_002D9c85_002D23db90ee4434/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="PostTagRelationsServiceTests" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;TestAncestor&gt;&#xD;
&lt;TestId&gt;xUnit::8AE98490-2264-4CBC-8B61-62DA16A2EC82::net5.0::Blog.ServicesTests.EntityServices.PostTagRelationsServiceTests&lt;/TestId&gt;&#xD;
Expand Down
15 changes: 15 additions & 0 deletions BlogWebApp/Blog.slnLaunch.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"Name": "New Profile",
"Projects": [
{
"Path": "Blog.Web\\Blog.Web.csproj",
"Action": "Start"
},
{
"Path": "BlogBlazor\\BlogBlazor.csproj",
"Action": "Start"
}
]
}
]
8 changes: 4 additions & 4 deletions BlogWebApp/Data/Blog.Data.Core/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Blog.Data.Core;

using System;
using Blog.Core;
using System;

/// <summary>
/// Entity.
Expand Down Expand Up @@ -74,13 +74,13 @@ public virtual bool Equals(Entity other)
var otherType = other.GetUnproxiedType();
var thisType = this.GetUnproxiedType();

return thisType.IsAssignableFrom(otherType) || otherType.IsAssignableFrom(thisType);
return otherType != null && (thisType.IsAssignableFrom(otherType) || otherType.IsAssignableFrom(thisType));
}

/// <inheritdoc cref="object"/>
public override int GetHashCode()
{
return Equals(this.Id, default(int)) ? base.GetHashCode() : this.Id.GetHashCode();
return Equals(this.Id, 0) ? base.GetHashCode() : this.Id.GetHashCode();
}

/// <summary>
Expand All @@ -90,7 +90,7 @@ public override int GetHashCode()
/// <returns>bool.</returns>
private static bool IsTransient(Entity obj)
{
return obj != null && Equals(obj.Id, default(int));
return obj != null && Equals(obj.Id, 0);
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions BlogWebApp/Data/Blog.Data.Core/Models/BaseDeletableModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Blog.Data.Core.Models;

using System;
using Blog.Core;
using Interfaces;
using System;

/// <summary>
/// Base deletable model.
Expand Down Expand Up @@ -89,13 +89,13 @@ public virtual bool Equals(BaseDeletableModel<TKey> other)
var otherType = other.GetUnproxiedType();
var thisType = this.GetUnproxiedType();

return thisType.IsAssignableFrom(otherType) || otherType.IsAssignableFrom(thisType);
return otherType != null && (thisType.IsAssignableFrom(otherType) || otherType.IsAssignableFrom(thisType));
}

/// <inheritdoc cref="object"/>
public override int GetHashCode()
{
return Equals(this.Id, default(int)) ? base.GetHashCode() : this.Id.GetHashCode();
return Equals(this.Id, 0) ? base.GetHashCode() : this.Id.GetHashCode();
}

/// <summary>
Expand All @@ -105,7 +105,7 @@ public override int GetHashCode()
/// <returns>bool.</returns>
private static bool IsTransient(BaseDeletableModel<TKey> obj)
{
return obj != null && Equals(obj.Id, default(int));
return obj != null && Equals(obj.Id, 0);
}

/// <summary>
Expand Down
12 changes: 4 additions & 8 deletions BlogWebApp/Data/Blog.Data.Core/Models/BaseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@

namespace Blog.Data.Core.Models;

using Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using Interfaces;

/// <summary>
/// Base model.
/// </summary>
/// <typeparam name="TKey">TKey.</typeparam>
public abstract class BaseModel<TKey> : IAuditInfo
public abstract class BaseModel<TKey>(TKey id)
: IAuditInfo
{
protected BaseModel(TKey id)
{
Id = id;
}

/// <summary>
/// Gets or sets id.
/// </summary>
[Key]
public TKey Id { get; }
public TKey Id { get; } = id;

/// <summary>
/// Gets or sets created on.
Expand Down
4 changes: 2 additions & 2 deletions BlogWebApp/Data/Blog.Data.Models/ApplicationUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Blog.Data.Models;

using System;
using System.Collections.Generic;
using Blog.Core;
using Blog.Data.Core.Models.Interfaces;
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;

/// <summary>
/// Application user entity.
Expand Down
3 changes: 1 addition & 2 deletions BlogWebApp/Data/Blog.Data.Models/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>

using Blog.Core.Enums;

namespace Blog.Data.Models;

using Blog.Core.Enums;
using Core;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion BlogWebApp/Data/Blog.Data.Models/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Blog.Data.Models;

using System;
using Core;
using System;

/// <summary>
/// Post entity.
Expand Down
2 changes: 1 addition & 1 deletion BlogWebApp/Data/Blog.Data.Models/PostsTagsRelations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Blog.Data.Models;
using Core;

/// <summary>
/// Posts Tags Many to Many Relations entity.
/// Posts Tags Many-to-Many Relations entity.
/// </summary>
/// <seealso cref="Entity" />
public class PostsTagsRelations : Entity
Expand Down
1 change: 0 additions & 1 deletion BlogWebApp/Data/Blog.Data.Models/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Blog.Data.Models;
/// <summary>
/// Setting.
/// </summary>

public class Setting : Entity
{
/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions BlogWebApp/Data/Blog.Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace Blog.Data;

using Blog.Data.Core.Models.Interfaces;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Models;
using System;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Blog.Data.Core.Models.Interfaces;
using Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

/// <summary>
/// Application database context.
Expand Down Expand Up @@ -159,7 +159,7 @@ protected override void OnModelCreating(ModelBuilder builder)
foreach (var deletableEntityType in deletableEntityTypes)
{
var method = SetIsDeletedQueryFilterMethod.MakeGenericMethod(deletableEntityType.ClrType);
method.Invoke(null, new object[] { builder });
method.Invoke(null, [builder]);
}

// Disable cascade delete
Expand Down
Loading
Loading