Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions Dentizone.Application/AutoMapper/Answers/AnswerProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using AutoMapper;

namespace Dentizone.Application.AutoMapper.Answers
{
public class AnswerProfile : Profile
{
public AnswerProfile()
{
CreateMap<Dentizone.Application.DTOs.Q_A.AnswerDTO.CreateAnswerDto, Dentizone.Domain.Entity.Answer>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => Guid.NewGuid().ToString()))
.ForMember(dest => dest.CreatedAt, opt => opt.MapFrom(src => DateTime.UtcNow))
.ReverseMap();
CreateMap<Dentizone.Application.DTOs.Q_A.AnswerDTO.UpdateAnswerDto, Dentizone.Domain.Entity.Answer>()
.ForMember(dest => dest.Text, opt => opt.MapFrom(src => src.Text))
.ForMember(dest => dest.UpdatedAt, opt => opt.MapFrom(src => DateTime.UtcNow))
.ReverseMap();
CreateMap<Dentizone.Application.DTOs.Q_A.AnswerDTO.AnswerViewDto, Dentizone.Domain.Entity.Answer>()
.ReverseMap();
}
}
}
27 changes: 27 additions & 0 deletions Dentizone.Application/AutoMapper/Questions/QuestionProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using AutoMapper;
using Dentizone.Application.DTOs.Q_A.QuestionDTO;

namespace Dentizone.Application.AutoMapper.Questions
{
public class QuestionProfile : Profile
{
public QuestionProfile()
{
CreateMap<CreateQuestionDto, Domain.Entity.Question>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => Guid.NewGuid().ToString()))
.ForMember(dest => dest.CreatedAt, opt => opt.MapFrom(src => DateTime.UtcNow))
.ReverseMap();
CreateMap<QuestionViewDto, Domain.Entity.Question>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.User, opt => opt.Ignore())
.ForMember(dest => dest.Text, opt => opt.MapFrom(src => src.Text))
.ForMember(dest => dest.CreatedAt, opt => opt.MapFrom(src => src.CreatedAt))
.ReverseMap()
.ForMember(dest => dest.AskerName, opt => opt.MapFrom(src => src.User != null ? src.User.FullName : string.Empty));
CreateMap<UpdateQuestionDto, Domain.Entity.Question>()
.ForMember(dest => dest.Text, opt => opt.MapFrom(src => src.Text))
.ForMember(dest => dest.UpdatedAt, opt => opt.MapFrom(src => DateTime.UtcNow))
.ReverseMap();
}
}
}
12 changes: 3 additions & 9 deletions Dentizone.Application/AutoMapper/WithdrawalProfile.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using AutoMapper;
using Dentizone.Application.DTOs.Withdrawal;
using Dentizone.Domain.Entity;

namespace Dentizone.Application.AutoMapper
{
public class WithdrawalProfile: Profile
public class WithdrawalProfile : Profile
{
public WithdrawalProfile()
{
Expand All @@ -18,6 +13,5 @@ public WithdrawalProfile()
.ForMember(dest => dest.UserId, opt => opt.MapFrom(src => src.Wallet.UserId.ToString()))
.ReverseMap();
}

}
}
}
1 change: 1 addition & 0 deletions Dentizone.Application/DI/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection
services.AddScoped<IReviewService, ReviewService>();

services.AddScoped<IWithdrawalService, WithdrawalService>();
services.AddScoped<IQAService, QAService>();
return services;
}
}
Expand Down
29 changes: 29 additions & 0 deletions Dentizone.Application/DTOs/Q&A/AnswerDTO/AnswerViewDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using FluentValidation;

namespace Dentizone.Application.DTOs.Q_A.AnswerDTO
{
public class AnswerViewDto
{
public string Id { get; set; }
public string ResponderName { get; set; }
public string Text { get; set; }
public DateTime CreatedAt { get; set; }
}

public class AnswerViewDtoValidator : AbstractValidator<AnswerViewDto>
{
public AnswerViewDtoValidator()
{
RuleFor(x => x.Id).NotEmpty().WithMessage("Id is required.");
RuleFor(x => x.ResponderName)
.NotEmpty().WithMessage("ResponderName is required.")
.MaximumLength(100).WithMessage("ResponderName cannot exceed 100 characters.");
RuleFor(x => x.Text)
.NotEmpty().WithMessage("Text is required.")
.MaximumLength(500).WithMessage("Text cannot exceed 500 characters.");
RuleFor(x => x.CreatedAt)
.Must(date => date != default).WithMessage("CreatedAt must be a valid date.")
.LessThanOrEqualTo(DateTime.UtcNow).WithMessage("CreatedAt cannot be in the future.");
}
}
}
20 changes: 20 additions & 0 deletions Dentizone.Application/DTOs/Q&A/AnswerDTO/CreateAnswerDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using FluentValidation;

namespace Dentizone.Application.DTOs.Q_A.AnswerDTO
{
public class CreateAnswerDto
{
public string Text { get; set; }
}

public class CreateAnswerDtoValidator : AbstractValidator<CreateAnswerDto>
{
public CreateAnswerDtoValidator()
{
RuleFor(x => x.Text)
.NotEmpty().WithMessage("Text is required.")
.MaximumLength(500).WithMessage("Text cannot exceed 500 characters.")
.Must(text => !string.IsNullOrWhiteSpace(text)).WithMessage("Text cannot be whitespace only.");
}
}
}
17 changes: 17 additions & 0 deletions Dentizone.Application/DTOs/Q&A/AnswerDTO/UpdateAnswerDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using FluentValidation;

namespace Dentizone.Application.DTOs.Q_A.AnswerDTO
{
public class UpdateAnswerDto
{
public string Text { get; set; }
}

public class UpdateAnswerDtoValidator : AbstractValidator<UpdateAnswerDto>
{
public UpdateAnswerDtoValidator()
{
RuleFor(x => x.Text).NotEmpty().WithMessage("Text is required.");
}
}
}
21 changes: 21 additions & 0 deletions Dentizone.Application/DTOs/Q&A/QuestionDTO/CreateQuestionDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Dentizone.Application.Validators;
using FluentValidation;

namespace Dentizone.Application.DTOs.Q_A.QuestionDTO
{
#nullable enable
public class CreateQuestionDto
{
public string PostId { get; set; }
public string? Text { get; set; }
}

public class CreateQuestionDtoValidator : AbstractValidator<CreateQuestionDto>
{
public CreateQuestionDtoValidator()
{
RuleFor(x => x.PostId).NotEmpty().WithMessage("PostId is required.").MustBeParsableGuid();
RuleFor(x => x.Text).NotEmpty().WithMessage("Text is required.");
}
}
}
25 changes: 25 additions & 0 deletions Dentizone.Application/DTOs/Q&A/QuestionDTO/QuestionViewDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Dentizone.Application.DTOs.Q_A.AnswerDTO;
using FluentValidation;

namespace Dentizone.Application.DTOs.Q_A.QuestionDTO
{
public class QuestionViewDto
{
public string Id { get; set; }
public string AskerName { get; set; }
public string Text { get; set; }
public AnswerViewDto? Answer { get; set; }
public DateTime CreatedAt { get; set; }
}

public class QuestionViewDtoValidator : AbstractValidator<QuestionViewDto>
{
public QuestionViewDtoValidator()
{
RuleFor(x => x.Id).NotEmpty().WithMessage("Id is required.");
RuleFor(x => x.AskerName).NotEmpty().WithMessage("AskerName is required.");
RuleFor(x => x.Text).NotEmpty().WithMessage("Text is required.");
RuleFor(x => x.CreatedAt).NotEmpty().WithMessage("CreatedAt is required.");
}
}
}
19 changes: 19 additions & 0 deletions Dentizone.Application/DTOs/Q&A/QuestionDTO/UpdateQuestionDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using FluentValidation;

namespace Dentizone.Application.DTOs.Q_A.QuestionDTO
{
public class UpdateQuestionDto
{
public string? Text { get; set; }
}

public class UpdateQuestionDtoValidator : AbstractValidator<UpdateQuestionDto>
{
public UpdateQuestionDtoValidator()
{
RuleFor(x => x.Text)
.NotEmpty().WithMessage("Text is required.")
.MaximumLength(500).WithMessage("Text cannot exceed 500 characters.");
}
}
}
10 changes: 2 additions & 8 deletions Dentizone.Application/DTOs/Withdrawal/ApproveWithdrawalDto.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dentizone.Application.DTOs.Withdrawal
namespace Dentizone.Application.DTOs.Withdrawal
{
public class ApproveWithdrawalDto
{
public string AdminNote { get; set; }
}
}
}
9 changes: 2 additions & 7 deletions Dentizone.Application/DTOs/Withdrawal/WithdrawalRequestDto.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 FluentValidation;
using FluentValidation;

namespace Dentizone.Application.DTOs.Withdrawal
{
Expand All @@ -24,4 +19,4 @@ public WithdrawalRequestDtoValidator()
.NotEmpty().WithMessage("Wallet ID is required.");
}
}
}
}
16 changes: 16 additions & 0 deletions Dentizone.Application/Interfaces/IQAService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Dentizone.Application.DTOs.Q_A.AnswerDTO;
using Dentizone.Application.DTOs.Q_A.QuestionDTO;

namespace Dentizone.Application.Interfaces
{
public interface IQAService
{
Task<QuestionViewDto> AskQuestionAsync(CreateQuestionDto dto, string askerId);
Task<IEnumerable<QuestionViewDto>> GetQuestionsForPostAsync(string postId);
Task<AnswerViewDto> AnswerQuestionAsync(string questionId, CreateAnswerDto dto, string responderId);
Task UpdateQuestionAsync(string questionId, UpdateQuestionDto dto);
Task DeleteQuestionAsync(string questionId);
Task UpdateAnswerAsync(string answerId, UpdateAnswerDto dto);
Task DeleteAnswerAsync(string answerId);
}
}
16 changes: 5 additions & 11 deletions Dentizone.Application/Interfaces/IWithdrawalService.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dentizone.Application.DTOs.Withdrawal;
using Dentizone.Domain.Entity;
using Dentizone.Application.DTOs.Withdrawal;

namespace Dentizone.Application.Interfaces
{
public interface IWithdrawalService
{
Task<WithdrawalRequestView> CreateWithdrawalRequestAsync(string userId, WithdrawalRequestDto withdrawalRequestDto);
Task<WithdrawalRequestView> CreateWithdrawalRequestAsync(string userId,
WithdrawalRequestDto withdrawalRequestDto);

Task<List<WithdrawalRequestView>> GetWithdrawalHistoryAsync(string userId, int page);
Task<WithdrawalRequestView> ApproveWithdrawalAsync(string id, string adminNote);
Task<WithdrawalRequestView> RejectWithdrawalAsync(string id, string adminNote);
}
}


}
7 changes: 1 addition & 6 deletions Dentizone.Application/Interfaces/Order/IShippingService.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 Dentizone.Domain.Enums;
using Dentizone.Domain.Enums;

namespace Dentizone.Application.Interfaces.Order
{
Expand Down
Loading
Loading