Skip to content

Commit 60f2e0c

Browse files
committed
Re-formatted for #19.
1 parent 481bbdc commit 60f2e0c

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,4 @@ FakesAssemblies/
194194

195195
# Visual Studio 6 workspace options file
196196
*.opt
197+
/src/AbpODataDemo.WebHost/Logs/Logs.txt

src/AbpODataDemo.WebApi/Controllers/AbpODataEntityController.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Linq;
1+
using System;
2+
using System.Linq;
3+
using System.Net;
24
using System.Net.Http;
35
using System.Threading;
46
using System.Threading.Tasks;
@@ -11,24 +13,26 @@
1113

1214
namespace AbpODataDemo.Controllers
1315
{
14-
public abstract class AbpODataEntityController<TEntity> : AbpODataEntityController<TEntity, int>
16+
public abstract class AbpODataEntityController<TEntity> : AbpODataEntityController<TEntity, int>
1517
where TEntity : class, IEntity<int>
1618
{
17-
protected AbpODataEntityController(IRepository<TEntity> repository) : base(repository)
19+
protected AbpODataEntityController(IRepository<TEntity> repository)
20+
: base(repository)
1821
{
1922

2023
}
2124
}
2225

2326
public abstract class AbpODataEntityController<TEntity, TPrimaryKey> : ODataController
24-
where TPrimaryKey: IEquatable<TPrimaryKey>
25-
where TEntity : class, IEntity<TPrimaryKey>
27+
where TPrimaryKey : IEquatable<TPrimaryKey>
28+
where TEntity : class, IEntity<TPrimaryKey>
2629
{
2730
public IUnitOfWorkManager UnitOfWorkManager { get; set; }
2831

2932
protected IRepository<TEntity, TPrimaryKey> Repository { get; private set; }
3033

3134
private IUnitOfWorkCompleteHandle _unitOfWorkCompleteHandler;
35+
3236
private bool _disposed;
3337

3438
protected AbpODataEntityController(IRepository<TEntity, TPrimaryKey> repository)
@@ -41,7 +45,7 @@ public override Task<HttpResponseMessage> ExecuteAsync(HttpControllerContext con
4145
_unitOfWorkCompleteHandler = UnitOfWorkManager.Begin();
4246
return base.ExecuteAsync(controllerContext, cancellationToken);
4347
}
44-
48+
4549
[EnableQuery]
4650
public IQueryable<TEntity> Get()
4751
{
@@ -61,6 +65,7 @@ public async Task<IHttpActionResult> Post(TEntity entity)
6165
{
6266
return BadRequest(ModelState);
6367
}
68+
6469
var created = await Repository.InsertAsync(entity);
6570
return Created(created);
6671
}
@@ -71,11 +76,13 @@ public async Task<IHttpActionResult> Patch([FromODataUri] TPrimaryKey key, Delta
7176
{
7277
return BadRequest(ModelState);
7378
}
79+
7480
var dbLookup = await Repository.GetAsync(key);
7581
if (entity == null)
7682
{
7783
return NotFound();
7884
}
85+
7986
entity.Patch(dbLookup);
8087
return Updated(entity);
8188
}
@@ -86,10 +93,12 @@ public async Task<IHttpActionResult> Put([FromODataUri] TPrimaryKey key, TEntity
8693
{
8794
return BadRequest(ModelState);
8895
}
96+
8997
if (!Equals(key, update.Id))
9098
{
9199
return BadRequest();
92100
}
101+
93102
var updated = await Repository.UpdateAsync(update);
94103
return Updated(updated);
95104
}
@@ -101,10 +110,11 @@ public async Task<IHttpActionResult> Delete([FromODataUri] TPrimaryKey key)
101110
{
102111
return NotFound();
103112
}
113+
104114
await Repository.DeleteAsync(key);
105115
return StatusCode(HttpStatusCode.NoContent);
106116
}
107-
117+
108118
protected override void Dispose(bool disposing)
109119
{
110120
if (!_disposed)

0 commit comments

Comments
 (0)