Skip to content

Instantly share code, notes, and snippets.

View mortezadalil's full-sized avatar

Morteza Dalil mortezadalil

View GitHub Profile
public abstract class UseCaseResponseMessage
{
public bool Success { get; }
public string Message { get; }
protected UseCaseResponseMessage(bool success = false, string message = null)
{
Success = success;
Message = message;
}
public class GenericResponse<T> : UseCaseResponseMessage
{
public T Data { get; }
public IEnumerable<Error> Errors { get; }
public GenericResponse(IEnumerable<Error> errors, bool success = false, string message = null) : base(success, message)
{
Errors = errors;
}
namespace Cms.Core.Dtos.Generals
{
public sealed class Error
{
public string Code { get; }
public string Description { get; }
public string Stack { get; }
public Error(string code, string description, string stack = "")
{
using System.Net;
using Cms.Core.Dtos.Generals;
using Cms.Core.IUseCases;
namespace Cms.Api.Presenters
{
public class PostApiPresenter<T> : IOutputPort<GenericResponse<T>>
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Cms.Core.Domain;
using Cms.Core.Dtos.Generals;
using Cms.Core.Dtos.UseCaseDtos;
using Cms.Core.IRepositories;
using Cms.Core.IUseCases;
public class AddPostRequest : IUseCaseRequest<GenericResponse<AddPostResponse>>
{
public string Title { get; set; }
public string Content { get; set; }
//public DateTime CreatedDate { get; set; }
//public DateTime ModifiedDate { get; set; }
}
public async Task<Post> Add(Post domain)
{
var post = new Enities.Post
{
Title = domain.Title,
CreatedDate = domain.CreatedDate,
ModifiedDate = domain.ModifiedDate,
Content = domain.Content
};
using System;
using System.Threading.Tasks;
using Cms.Core.Dtos.Generals;
using Cms.Core.Dtos.UseCaseDtos;
using Cms.Core.Exceptions;
using Cms.Core.IRepositories;
using Cms.Core.IUseCases;
namespace Cms.Core.UseCases
{
[HttpGet("GetAll")]
public async Task<IActionResult> GetAll()
{
var query = new GetAllPostQuery();
}
using MediatR;
using System.Collections.Generic;
using Cms.Core.Dtos;
namespace Cms.Core.Queries
{
public class GetAllPostQuery:IRequest<List<PostWithoutCommentsDto>>
{
}