添加命令数据验证和其他杂项修改

This commit is contained in:
2021-02-24 16:28:08 +08:00
parent 12ecdf3159
commit 41794aa1bc
32 changed files with 310 additions and 484 deletions

View File

@@ -1,5 +1,6 @@
using Domain.AggregateModel.LinkAggregate;
using Domain.SeedWork;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,16 +11,33 @@ namespace Infrastructure.Repositories
{
public class LinkRepository : ILinkRepository
{
public IUnitOfWork UnitOfWork => throw new NotImplementedException();
private AppDbContext dbContext;
public void Add(Link link)
public LinkRepository(AppDbContext dbContext)
{
throw new NotImplementedException();
this.dbContext = dbContext;
}
public Task<Link> GetAsync(string shortCode)
public IUnitOfWork UnitOfWork => dbContext;
public Link Add(Link link)
{
throw new NotImplementedException();
if (link.IsTransient())
{
return dbContext.Links.Add(link).Entity;
}
else
{
return link;
}
}
public async Task<Link> GetAsync(string shortCode)
{
var link = await dbContext.Links
.Where(l => l.ShortCode==shortCode)
.SingleOrDefaultAsync();
return link;
}
}
}