Skip to content

Commit

Permalink
correct conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
hnjm committed Nov 3, 2024
2 parents bee4ffb + 4341f7e commit f699bec
Show file tree
Hide file tree
Showing 57 changed files with 476 additions and 386 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Here are some projects that have been developed based on this Clean Architecture
3. **Visitor Management**
- [GitHub Repository](https://github.com/neozhu/visitormanagement)

[![School Bus Transport Management System Screenshot](https://private-user-images.githubusercontent.com/1549611/375740905-a79a8c54-82bd-475a-95f9-c20fe368179d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mjk3NzUyNDAsIm5iZiI6MTcyOTc3NDk0MCwicGF0aCI6Ii8xNTQ5NjExLzM3NTc0MDkwNS1hNzlhOGM1NC04MmJkLTQ3NWEtOTVmOS1jMjBmZTM2ODE3OWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MTAyNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDEwMjRUMTMwMjIwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDA2NjU3ZjVlZjFhMTgwOWRkM2ZlMzMzOTZkNGU2MGQ5MDI4YjBlNmU5YTA0NmM0NDVhYzgwNzgxZTU2MWY5YSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.cHwoUvOuhpSke0wr6ziUSbW-5hC24D2vlN4BSWzTBwc)](https://schoolbus.blazorserver.com/)
[![School Bus Transport Management System Screenshot](https://github.com/user-attachments/assets/0874eb1d-ce6a-4bdc-b716-9fb7dbce2186)](https://schoolbus.blazorserver.com/)
4. **School Bus Transport Management System**
- [GitHub Repository](https://github.com/neozhu/schoolbus)

Expand Down
4 changes: 1 addition & 3 deletions src/Application/Common/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

public static class DateTimeExtensions
public static class DateTimeExtensions
{
/// <summary>
/// Gets a date range based on the provided keyword, similar to Salesforce date keywords.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CleanArchitecture.Blazor.Application.Common.Extensions;
namespace CleanArchitecture.Blazor.Application.Common.Extensions;

/// <summary>
/// Provides extension methods for <see cref="ISpecificationBuilder{T}"/> to simplify query building.
Expand Down
3 changes: 2 additions & 1 deletion src/Application/Common/Interfaces/IUploadService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace CleanArchitecture.Blazor.Application.Common.Interfaces;

public interface IUploadService
{
Task<string> UploadAsync(UploadRequest request);
void Remove(string filename);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Collections.Concurrent;
using System.Collections.Concurrent;

namespace CleanArchitecture.Blazor.Application.Common.Interfaces.Identity;

public interface IUsersStateContainer
{
ConcurrentDictionary<string, string> UsersByConnectionId { get; }
event Action? OnChange;
void AddOrUpdate(string connectionId, string? name);
void AddOrUpdate(string connectionId, string? userId);
void Remove(string connectionId);
void Clear(string userId);
}
12 changes: 0 additions & 12 deletions src/Application/Common/Models/MailRequest.cs

This file was deleted.

3 changes: 2 additions & 1 deletion src/Application/Common/Models/UploadRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace CleanArchitecture.Blazor.Application.Common.Models;

public class UploadRequest
{
public UploadRequest(string fileName, UploadType uploadType, byte[] data, bool overwrite=false)
public UploadRequest(string fileName, UploadType uploadType, byte[] data, bool overwrite = false)
{
FileName = fileName;
UploadType = uploadType;
Expand All @@ -18,4 +18,5 @@ public UploadRequest(string fileName, UploadType uploadType, byte[] data, bool o
public UploadType UploadType { get; set; }
public bool Overwrite { get; set; }
public byte[] Data { get; set; }
public string? Folder { get; set; }
}
9 changes: 1 addition & 8 deletions src/Application/Common/Security/ChangeUserProfileModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CleanArchitecture.Blazor.Application.Features.Documents.Commands.AddEdit;
using CleanArchitecture.Blazor.Application.Features.Documents.DTOs;
using CleanArchitecture.Blazor.Application.Features.Identity.DTOs;
using CleanArchitecture.Blazor.Application.Features.Identity.DTOs;

namespace CleanArchitecture.Blazor.Application.Common.Security;
public class ChangeUserProfileModel
Expand Down
4 changes: 1 addition & 3 deletions src/Application/Common/Security/UserProfile.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using CleanArchitecture.Blazor.Application.Features.Identity.DTOs;

namespace CleanArchitecture.Blazor.Application.Common.Security;
namespace CleanArchitecture.Blazor.Application.Common.Security;

public class UserProfile
{
Expand Down
7 changes: 1 addition & 6 deletions src/Application/Common/Security/UserProfileStateService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CleanArchitecture.Blazor.Application.Features.Identity.DTOs;
using CleanArchitecture.Blazor.Application.Features.Identity.DTOs;
using CleanArchitecture.Blazor.Domain.Identity;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using CleanArchitecture.Blazor.Application.Common.Security;
using CleanArchitecture.Blazor.Application.Common.Security;

namespace CleanArchitecture.Blazor.Application.Features.AuditTrails.Specifications;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.ComponentModel;
using CleanArchitecture.Blazor.Application.Features.Contacts.DTOs;
using CleanArchitecture.Blazor.Application.Features.Contacts.Caching;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.ComponentModel;
using CleanArchitecture.Blazor.Application.Features.Contacts.DTOs;
using CleanArchitecture.Blazor.Application.Features.Contacts.Caching;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using CleanArchitecture.Blazor.Application.Features.Contacts.DTOs;
using CleanArchitecture.Blazor.Application.Features.Contacts.Specifications;
using CleanArchitecture.Blazor.Application.Features.Contacts.Queries.Pagination;

namespace CleanArchitecture.Blazor.Application.Features.Contacts.Queries.Export;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using CleanArchitecture.Blazor.Application.Features.Documents.Specifications;
using CleanArchitecture.Blazor.Application.Features.Products.Specifications;

namespace CleanArchitecture.Blazor.Application.Features.Contacts.Specifications;
namespace CleanArchitecture.Blazor.Application.Features.Contacts.Specifications;
#nullable disable warnings
/// <summary>
/// Specification class for advanced filtering of Contacts.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using CleanArchitecture.Blazor.Application.Common.Security;

namespace CleanArchitecture.Blazor.Application.Features.Documents.Specifications;
namespace CleanArchitecture.Blazor.Application.Features.Documents.Specifications;

public enum DocumentListView
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using CleanArchitecture.Blazor.Application.Features.Products.Specifications;

namespace CleanArchitecture.Blazor.Application.Features.Documents.Specifications;
namespace CleanArchitecture.Blazor.Application.Features.Documents.Specifications;
#nullable disable warnings
public class AdvancedDocumentsSpecification : Specification<Document>
{
Expand Down
3 changes: 1 addition & 2 deletions src/Application/Features/Identity/DTOs/ApplicationUserDto.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CleanArchitecture.Blazor.Application.Common.Security;
using CleanArchitecture.Blazor.Application.Features.Tenants.DTOs;
using CleanArchitecture.Blazor.Application.Features.Tenants.DTOs;
using CleanArchitecture.Blazor.Domain.Identity;

namespace CleanArchitecture.Blazor.Application.Features.Identity.DTOs;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using CleanArchitecture.Blazor.Application.Common.Security;

namespace CleanArchitecture.Blazor.Application.Features.Identity.Notifications;
namespace CleanArchitecture.Blazor.Application.Features.Identity.Notifications;

public class UpdateUserProfileCommand : INotification
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using CleanArchitecture.Blazor.Application.Common.Security;

namespace CleanArchitecture.Blazor.Application.Features.Products.Specifications;
namespace CleanArchitecture.Blazor.Application.Features.Products.Specifications;

public class ProductAdvancedFilter : PaginationFilter
{
Expand Down
1 change: 0 additions & 1 deletion src/Application/Pipeline/AuthorizationBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using CleanArchitecture.Blazor.Application.Common.Interfaces.Identity;
using CleanArchitecture.Blazor.Application.Common.Security;

namespace CleanArchitecture.Blazor.Application.Pipeline;

Expand Down
1 change: 0 additions & 1 deletion src/Domain/Identity/ApplicationUser.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel.DataAnnotations.Schema;
using CleanArchitecture.Blazor.Domain.Common.Entities;

namespace CleanArchitecture.Blazor.Domain.Identity;
Expand Down
42 changes: 39 additions & 3 deletions src/Infrastructure/Services/Identity/UsersStateContainer.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,63 @@
using System.Collections.Concurrent;
using System.Collections.Concurrent;

namespace CleanArchitecture.Blazor.Infrastructure.Services.Identity;


/// <summary>
/// Manages the state of users by their connection IDs.
/// </summary>
public class UsersStateContainer : IUsersStateContainer
{
/// <summary>
/// Gets the dictionary that maps connection IDs to user names.
/// </summary>
public ConcurrentDictionary<string, string> UsersByConnectionId { get; } = new();

/// <summary>
/// Event triggered when the state changes.
/// </summary>
public event Action? OnChange;

/// <summary>
/// Adds or updates a user in the state container.
/// </summary>
/// <param name="connectionId">The connection ID of the user.</param>
/// <param name="name">The name of the user.</param>
public void AddOrUpdate(string connectionId, string? name)
{
UsersByConnectionId.AddOrUpdate(connectionId, name ?? string.Empty, (key, oldValue) => name ?? string.Empty);
NotifyStateChanged();
}

/// <summary>
/// Removes a user from the state container by their connection ID.
/// </summary>
/// <param name="connectionId">The connection ID of the user to remove.</param>
public void Remove(string connectionId)
{
UsersByConnectionId.TryRemove(connectionId, out var _);
UsersByConnectionId.TryRemove(connectionId, out _);
NotifyStateChanged();
}

/// <summary>
/// Clears all users with the specified name from the state container.
/// </summary>
/// <param name="userName">The name of the user to clear.</param>
public void Clear(string userName)
{
var keysToRemove = UsersByConnectionId.Where(kvp => kvp.Value == userName).Select(kvp => kvp.Key).ToList();
foreach (var key in keysToRemove)
{
UsersByConnectionId.TryRemove(key, out _);
}
NotifyStateChanged();
}

/// <summary>
/// Notifies subscribers that the state has changed.
/// </summary>
private void NotifyStateChanged()
{
OnChange?.Invoke();
}
}
}
22 changes: 20 additions & 2 deletions src/Infrastructure/Services/UploadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ public async Task<string> UploadAsync(UploadRequest request)

var folder = request.UploadType.GetDescription();
var folderName = Path.Combine("Files", folder);
if (!string.IsNullOrEmpty(request.Folder))
{
folderName = Path.Combine(folderName, request.Folder);
}
var pathToSave = Path.Combine(Directory.GetCurrentDirectory(), folderName);
Directory.CreateDirectory(pathToSave);
if (!Directory.Exists(pathToSave))
{
Directory.CreateDirectory(pathToSave);
}

var fileName = request.FileName.Trim('"');
var fullPath = Path.Combine(pathToSave, fileName);
Expand All @@ -43,7 +50,18 @@ public async Task<string> UploadAsync(UploadRequest request)

return dbPath;
}

/// <summary>
/// remove file
/// </summary>
/// <param name="filename"></param>
public void Remove(string filename)
{
var removefile = Path.Combine(Directory.GetCurrentDirectory(), filename);
if (File.Exists(removefile))
{
File.Delete(removefile);
}
}
/// <summary>
/// Gets the next available filename based on the given path.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ public class PickSuperiorIdAutocomplete<T> : MudAutocomplete<ApplicationUserDto>

[Parameter] public string? TenantId { get; set; }
[Parameter] public string? OwnerName { get; set; }

[Inject] private IUserService UserService { get; set; } = default!;


public PickSuperiorIdAutocomplete()
{

Expand All @@ -23,11 +20,6 @@ public PickSuperiorIdAutocomplete()
ShowProgressIndicator = true;
MaxItems = 200;
}





private Task<IEnumerable<ApplicationUserDto>> SearchKeyValues(string value, CancellationToken cancellation)
{
IEnumerable<ApplicationUserDto> result= UserService.DataSource.Where(x => (x.TenantId!=null && x.TenantId.Equals(TenantId)) && !x.UserName.Equals(OwnerName));
Expand All @@ -38,8 +30,6 @@ private Task<IEnumerable<ApplicationUserDto>> SearchKeyValues(string value, Canc
}
return Task.FromResult(result);
}


protected override void OnInitialized()
{
UserService.OnChange += TenantsService_OnChange;
Expand All @@ -49,7 +39,6 @@ private async Task TenantsService_OnChange()
{
await InvokeAsync(StateHasChanged);
}

protected override void Dispose(bool disposing)
{
UserService.OnChange -= TenantsService_OnChange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ namespace CleanArchitecture.Blazor.Server.UI.Components.Autocompletes;

public class PickUserAutocomplete<T> : MudAutocomplete<ApplicationUserDto>
{

public PickUserAutocomplete()
public PickUserAutocomplete()
{
SearchFunc = SearchKeyValues;
ToStringFunc = dto => dto?.UserName;
Expand Down Expand Up @@ -35,9 +34,6 @@ protected override void Dispose(bool disposing)
UserService.OnChange -= TenantsService_OnChange;
base.Dispose(disposing);
}



private Task<IEnumerable<ApplicationUserDto>> SearchKeyValues(string value,CancellationToken cancellation)
{
IEnumerable<ApplicationUserDto> result = UserService.DataSource.Where(x =>x.TenantId!=null && x.TenantId.Equals(TenantId));
Expand Down
4 changes: 2 additions & 2 deletions src/Server.UI/Components/Breadcrumbs/Breadcrumbs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

@if (OnSaveButtonClick.HasDelegate)
{
<MudLoadingButton StartIcon="@Icons.Material.Filled.Save" Color="Color.Primary" DropShadow="false" Loading="@Saving" Variant="Variant.Outlined" OnClick="@Save">@ConstantString.Save</MudLoadingButton>
<MudLoadingButton StartIcon="@Icons.Material.Filled.Save" Color="Color.Primary" DropShadow="false" Loading="@Saving" OnClick="@Save">@ConstantString.Save</MudLoadingButton>
}
@if (OnGoEditClick.HasDelegate)
{
<MudButton StartIcon="@Icons.Material.Filled.Edit" Color="Color.Primary" Variant="Variant.Outlined" OnClick="@GoEdit">@ConstantString.Edit</MudButton>
<MudButton StartIcon="@Icons.Material.Filled.Edit" Color="Color.Primary" OnClick="@GoEdit">@ConstantString.Edit</MudButton>
}
@if (OnDeleteClick.HasDelegate || OnPrintClick.HasDelegate)
{
Expand Down
Loading

0 comments on commit f699bec

Please sign in to comment.