-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mtai0524/dev
chors: use interface repo, config cloud clean architecture
- Loading branch information
Showing
28 changed files
with
242 additions
and
212 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
NotaionWebApp/Notaion.Application/Common/Interfaces/ICloudinaryService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Notaion.Application.Common.Interfaces | ||
{ | ||
public interface ICloudinaryService | ||
{ | ||
Task<string> UploadImageAsync(IFormFile imageFile); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Notaion.Domain.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations.Schema; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Notaion.Application.DTOs | ||
{ | ||
public class GetChatRequest | ||
{ | ||
public string? Content { get; set; } | ||
public DateTime? SentDate { get; set; } | ||
public string? UserName { get; set; } | ||
public bool IsHiden { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Notaion.Application | ||
{ | ||
public static class DependencyInjection | ||
{ | ||
public static IServiceCollection AddApplication(this IServiceCollection services) | ||
{ | ||
services.AddAutoMapper(Assembly.GetExecutingAssembly()); | ||
return services; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using AutoMapper; | ||
using Notaion.Application.DTOs; | ||
using Notaion.Domain.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Notaion.Application.Mapper | ||
{ | ||
public class ChatProfile : Profile | ||
{ | ||
public ChatProfile() | ||
{ | ||
CreateMap<Chat, GetChatRequest>() | ||
.ForMember(dest => dest.IsHiden, opt => opt.MapFrom(src => src.Hide)); // config auto mapper - prefix | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
NotaionWebApp/Notaion.Application/Repositories/IChatRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Notaion.Application.DTOs; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Notaion.Application.Repositories | ||
{ | ||
public interface IChatRepository | ||
{ | ||
List<GetChatRequest> GetChats(); | ||
List<GetChatRequest> GetChatsHide(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Notaion.Domain.Entities | ||
{ | ||
public class User : IdentityUser | ||
{ | ||
public string? Avatar { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
NotaionWebApp/Notaion.Infrastructure/DependencyInjection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Notaion.Application.Common.Interfaces; | ||
using Notaion.Application.Repositories; | ||
using Notaion.Infrastructure.Context; | ||
using Notaion.Infrastructure.Persistence; | ||
using Notaion.Infrastructure.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Notaion.Infrastructure | ||
{ | ||
public static class DependencyInjection | ||
{ | ||
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
var connectionString = configuration.GetConnectionString("DefaultConnection"); | ||
|
||
services.AddDbContext<ApplicationDbContext>(options => | ||
{ | ||
options.UseSqlServer(connectionString); | ||
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking); | ||
}, ServiceLifetime.Singleton, ServiceLifetime.Transient); | ||
|
||
services.AddScoped<IChatRepository, ChatRepository>(); | ||
services.AddScoped<ICloudinaryService, CloudinaryService>(); | ||
return services; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
NotaionWebApp/Notaion.Infrastructure/Options/CloudinaryOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Notaion.Infrastructure.Options | ||
{ | ||
public class CloudinaryOptions | ||
{ | ||
public string CloudName { get; set; } | ||
public string ApiKey { get; set; } | ||
public string ApiSecret { get; set; } | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
NotaionWebApp/Notaion.Infrastructure/Persistence/ChatRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using AutoMapper; | ||
using Notaion.Application.DTOs; | ||
using Notaion.Application.Repositories; | ||
using Notaion.Domain.Entities; | ||
using Notaion.Infrastructure.Context; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Notaion.Infrastructure.Persistence | ||
{ | ||
public class ChatRepository : IChatRepository | ||
{ | ||
private readonly ApplicationDbContext _context; | ||
private readonly IMapper _mapper; | ||
public ChatRepository(ApplicationDbContext context, IMapper mapper) | ||
{ | ||
_context = context; | ||
_mapper = mapper; | ||
} | ||
public List<GetChatRequest> GetChats() | ||
{ | ||
return this._context.Chat | ||
.OrderBy(c => c.SentDate) | ||
.Where(x => x.Hide == false) | ||
.ToList() | ||
.Select(p => this._mapper.Map<GetChatRequest>(p)).ToList(); | ||
} | ||
|
||
public List<GetChatRequest> GetChatsHide() | ||
{ | ||
return this._context.Chat | ||
.OrderBy(c => c.SentDate) | ||
.Where(x => x.Hide == true) | ||
.ToList() | ||
.Select(p => this._mapper.Map<GetChatRequest>(p)).ToList(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.