添加命令数据验证和其他杂项修改
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user