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

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.AppAggregate;
using Domain.SeedWork;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,16 +11,31 @@ namespace Infrastructure.Repositories
{
public class AppRepository : IAppRepository
{
public IUnitOfWork UnitOfWork => throw new NotImplementedException();
private readonly AppDbContext dbContext;
public void Add(App app)
public AppRepository(AppDbContext dbContext)
{
throw new NotImplementedException();
this.dbContext = dbContext;
}
public Task<App> GetAsync(int id)
public IUnitOfWork UnitOfWork => dbContext;
public App Add(App app)
{
throw new NotImplementedException();
if (app.IsTransient())
{
return dbContext.Apps.Add(app).Entity;
}
else
{
return app;
}
}
public async Task<App> GetAsync(int id)
{
var app = await dbContext.Apps.Where(a => a.Id == id).SingleOrDefaultAsync();
return app;
}
}
}