Skip to content

Commit

Permalink
🍒 remove unnecessary using
Browse files Browse the repository at this point in the history
  • Loading branch information
neozhu committed Nov 2, 2024
1 parent f464278 commit 9976298
Show file tree
Hide file tree
Showing 23 changed files with 37 additions and 85 deletions.
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);
}
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,6 +1,4 @@
using CleanArchitecture.Blazor.Application.Common.Security;

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

public enum AuditTrailListView
{
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
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

0 comments on commit 9976298

Please sign in to comment.