Skip to content

Commit

Permalink
Merge pull request #2 from Mstaheri/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Mstaheri authored Jul 27, 2024
2 parents 2a1c63f + 920c997 commit 2f56997
Show file tree
Hide file tree
Showing 47 changed files with 7,144 additions and 134 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/dotnet-first.yml

This file was deleted.

50 changes: 37 additions & 13 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
name: dotnet package
name: Mstaheri Development pipeline

on: [push]
on:
push:
branches: ["develop"]
pull_request:
branches: ["develop"]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '3.1.x', '6.0.x' ]

steps:
- uses: actions/checkout@v4
- name: Setup dotnet ${{ matrix.dotnet-version }}
- uses: actions/checkout@v3

- name: setup .Net
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
# You can test your matrix by printing the current dotnet version
- name: Display dotnet version
run: dotnet --version
dotnet-version: 7.0.x

- name: Restore Dependency
run: dotnet restore MSTSandogh.sln

- name: Build
run: dotnet build MSTSandogh.sln --no-restore

- name: Test
run: dotnet test MSTSandogh.sln --no-build --verbosity normal

- name: Publish
run: dotnet publish MSTSandogh.sln -c release --output ./Release

- name: App Setting Variable
uses: microsoft/variable-substitution@v1
with:
files: './Release/appsettings.json'
env:
ConnectionStrings.sqlServer: ${{secrets.CONNECTION_STRING}}

- name: FTP Deploy
uses: SamKirkland/FTP-Deploy-Action@v4.3.4
with:
server: ${{secrets.ftp_server}}
username: ${{secrets.ftp_user}}
password: ${{secrets.ftp_password}}
local-dir: ./Release/
8 changes: 4 additions & 4 deletions Application/Data/MoqData/BankSafeDocumentMoqData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class BankSafeDocumentMoqData
public Task<BankSafeDocument> Get()
{
BankSafeDocument bankSafeDocument = new BankSafeDocument("ali",
"1234123412341234" , "1403/02/3" , "1403/06/05", 1122,
"1234123412341234" , "1403/02/03" , "1403/06/05", 1122,
0 , SituationTypes.Confirmed);

return Task.FromResult(bankSafeDocument);
Expand All @@ -23,10 +23,10 @@ public Task<List<BankSafeDocument>> GetAll()
List<BankSafeDocument> list = new List<BankSafeDocument>()
{
new BankSafeDocument("ali",
"1234123412341234" , "1403/02/3" , "1403/06/05", 1122,
0 , SituationTypes.UnderReview) ,
"1234123412341234" , "1403/02/03" , "1403/06/05", 1122,
1 , SituationTypes.UnderReview) ,
new BankSafeDocument("ali",
"1234123412341234" , "1403/02/3" , "1403/06/05",0,
"1234123412341234" , "1403/02/03" , "1403/06/05",0,
21432 , SituationTypes.Returned)
};
return Task.FromResult(list);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Domain.Exceptions;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.Services.ChatRoom.Commands.AddChatRoom
{
public record AddChatRoomCommand : IRequest<OperationResult<Guid>>
{
public required string ConnectionId { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Application.Services.Loan.Commands.AddLoan;
using Application.UnitOfWork;
using Domain.Entity;
using Domain.Exceptions;
using Domain.IRepositories;
using Glimpse.Core.Extensibility;
using MediatR;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.Services.ChatRoom.Commands.AddChatRoom
{
public class AddChatRoomCommandHandler
: IRequestHandler<AddChatRoomCommand, OperationResult<Guid>>
{
public AddChatRoomCommandHandler(IUnitOfWork unitOfWork,
IChatRoomRepositorie chatRoomRepositorie,
ILogger<AddChatRoomCommandHandler> logger)
{
_unitOfWork = unitOfWork;
_chatRoomRepositorie = chatRoomRepositorie;
_logger = logger;
}
private readonly IUnitOfWork _unitOfWork;
private readonly IChatRoomRepositorie _chatRoomRepositorie;
private readonly ILogger<AddChatRoomCommandHandler> _logger;
public async Task<OperationResult<Guid>> Handle(AddChatRoomCommand request, CancellationToken cancellationToken)
{
try
{
var chatRomm = new Domain.Entity.ChatRoom(request.ConnectionId);
await _chatRoomRepositorie.AddAsync(chatRomm);
await _unitOfWork.SaveChangesAsync(cancellationToken);

string message = string.Format(ConstMessages.Successfully
, chatRomm.ConnectionId
, nameof(AddChatRoomCommandHandler));
_logger.LogInformation(message);
return new OperationResult<Guid>(true, null , chatRomm.Id);
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
return new OperationResult<Guid>(false, ex.Message , Guid.Empty);
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Application.Services.Loan.Commands.AddLoan;
using Domain.Exceptions;
using FluentValidation;
using FluentValidation.Results;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.Services.ChatRoom.Commands.AddChatRoom
{
public class AddChatRoomCommandValidator : AbstractValidator<AddChatRoomCommand>
{
public AddChatRoomCommandValidator()
{
RuleFor(p => p.ConnectionId)
.NotNull().WithMessage(string.Format(ConstMessages.IsNull, "ConnectionId"))
.MaximumLength(23).WithMessage(string.Format(ConstMessages.MaximumLength, "ConnectionId", "23"));
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.Services.ChatRoom.Queries.GetChatRoomByConnectionId
{
public record GetChatRoomByConnectionIdQuery : IRequest<Guid>
{
public required string ConnectionId { get; init; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Application.Services.Loan.Queries.GetAllLoan;
using Application.Services.Loan.Queries.GetByCodeLoan;
using Domain.Exceptions;
using Domain.IRepositories;
using MediatR;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.Services.ChatRoom.Queries.GetChatRoomByConnectionId
{
public class GetChatRoomByConnectionIdQueryHandler :
IRequestHandler<GetChatRoomByConnectionIdQuery, Guid>
{
private readonly IChatRoomRepositorie _chatRoomRepositorie;
private readonly ILogger<GetChatRoomByConnectionIdQueryHandler> _logger;
public GetChatRoomByConnectionIdQueryHandler(IChatRoomRepositorie chatRoomRepositorie
, ILogger<GetChatRoomByConnectionIdQueryHandler> logger)
{
_chatRoomRepositorie = chatRoomRepositorie;
_logger = logger;
}
public async Task<Guid> Handle(GetChatRoomByConnectionIdQuery request, CancellationToken cancellationToken)
{
try
{
var result = await _chatRoomRepositorie.GetChatRoomByConnectionId
(request.ConnectionId, cancellationToken);
string message = string.Format(ConstMessages.Successfully
, nameof(GetChatRoomByConnectionIdQueryHandler)
, "");
_logger.LogInformation(message);
if (result != null)
{
return result.Id;
}
else
{
return Guid.Empty;
}

}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
return Guid.Empty;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace Application.Services.Loan.Commands.DeleteLoan
{
public record DeleteLoanCommand : IRequest<OperationResult>
{
public required Guid Code { get; init; }
public required System.Guid Code { get; init; }
}
}
22 changes: 22 additions & 0 deletions Domain/Entity/ChatRoom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Domain.Attributes;
using Domain.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domain.Entity
{
[AudiTable]
public class ChatRoom : IEntity
{
public ChatRoom(string connectionId)
{
Id = Guid.NewGuid();
ConnectionId = connectionId;
}
public Guid Id { get; private set; }
public string ConnectionId { get; private set; }
}
}
1 change: 0 additions & 1 deletion Domain/Exceptions/ConstMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace Domain.Exceptions
{
Expand Down
16 changes: 16 additions & 0 deletions Domain/IRepositories/IChatRoomRepositorie.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Domain.Entity;
using Domain.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domain.IRepositories
{
public interface IChatRoomRepositorie
{
ValueTask AddAsync(ChatRoom chatRoom);
Task<ChatRoom> GetChatRoomByConnectionId(string connectionId , CancellationToken cancellationToken);
}
}
2 changes: 1 addition & 1 deletion Infrastructure/Repositories/BankSafeDocumentRepositorie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task<List<BankSafeDocument>> GetAllAsync(CancellationToken cancella
return result;
}

public async Task<BankSafeDocument> GetAsync(Guid code , CancellationToken cancellationToken)
public async Task<BankSafeDocument> GetAsync(System.Guid code , CancellationToken cancellationToken)
{
var result = await _bankSafeDocument.FirstOrDefaultAsync(p => p.Code == code, cancellationToken);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task<List<BankSafeTransaction>> GetAllAsync(CancellationToken cance
return result;
}

public async Task<BankSafeTransaction> GetAsync(Guid code , CancellationToken cancellationToken)
public async Task<BankSafeTransaction> GetAsync(System.Guid code , CancellationToken cancellationToken)
{
var result = await _bankSafeTransactions
.FirstOrDefaultAsync(p => p.Code == code , cancellationToken);
Expand Down
Loading

0 comments on commit 2f56997

Please sign in to comment.