init project
This commit is contained in:
14
QRCodeService/Application/Commands/CreateLinkCommand.cs
Normal file
14
QRCodeService/Application/Commands/CreateLinkCommand.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using MediatR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QRCodeService.Application.Commands
|
||||
{
|
||||
public class CreateLinkCommand : IRequest<bool>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using MediatR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QRCodeService.Application.Commands
|
||||
{
|
||||
public class CreateLinkCommandHandler : IRequestHandler<CreateLinkCommand, bool>
|
||||
{
|
||||
public Task<bool> Handle(CreateLinkCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
13
QRCodeService/Application/Queries/GetLinkQueryHandler.cs
Normal file
13
QRCodeService/Application/Queries/GetLinkQueryHandler.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QRCodeService.Application.Queries
|
||||
{
|
||||
public class GetLinkQueryHandler
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
13
QRCodeService/Application/Queries/ILinkQueries.cs
Normal file
13
QRCodeService/Application/Queries/ILinkQueries.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QRCodeService.Application.Queries
|
||||
{
|
||||
public interface ILinkQueries
|
||||
{
|
||||
Task<Link> GetLinkAsync(string shortCode);
|
||||
}
|
||||
}
|
||||
32
QRCodeService/Application/Queries/LinkQueries.cs
Normal file
32
QRCodeService/Application/Queries/LinkQueries.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using MediatR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using MySqlConnector;
|
||||
|
||||
namespace QRCodeService.Application.Queries
|
||||
{
|
||||
public class LinkQueries : ILinkQueries
|
||||
{
|
||||
readonly string _connectionString;
|
||||
|
||||
public LinkQueries(string connectionString)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
}
|
||||
|
||||
public async Task<Link> GetLinkAsync(string shortCode)
|
||||
{
|
||||
using(var connection = new MySqlConnection(_connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
var link = await connection.QueryAsync<Link>(
|
||||
@"SELECT A FROM B WHERE ShortCode = @shortCode",new {shortCode });
|
||||
return link.Single();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
15
QRCodeService/Application/Queries/LinkViewModel.cs
Normal file
15
QRCodeService/Application/Queries/LinkViewModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QRCodeService.Application.Queries
|
||||
{
|
||||
public class Link
|
||||
{
|
||||
public string ShortCode { get; set; }
|
||||
|
||||
public string FullUrl { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user