Add Intermediate AutoGetterDeleteCotnroller
This commit is contained in:
parent
ebd8f5be92
commit
386ef6fa54
|
|
@ -33,7 +33,7 @@ namespace NejCommon.Controllers
|
|||
/// <typeparam name="TRequest">The request type</typeparam>
|
||||
/// <typeparam name="TResponse">The response type</typeparam>
|
||||
[ApiController]
|
||||
public abstract partial class AutoController<TOwner, TType, TGetAllResponse, TCreateRequest, TCreateResponse, TGetResponse, TUpdateRequest, TUpdateResponse> : AutoGetterController<TOwner, TType, TGetAllResponse, TGetResponse>
|
||||
public abstract partial class AutoController<TOwner, TType, TGetAllResponse, TCreateRequest, TCreateResponse, TGetResponse, TUpdateRequest, TUpdateResponse> : AutoGetterDeleteController<TOwner, TType, TGetAllResponse, TGetResponse>
|
||||
where TType : class
|
||||
where TGetAllResponse : class, IAutomappedAttribute<TType, TGetAllResponse>, new()
|
||||
where TCreateRequest : class, IAutomappedAttribute<TType, TCreateRequest>, new()
|
||||
|
|
@ -87,21 +87,6 @@ namespace NejCommon.Controllers
|
|||
return await db.ApiSaveChangesAsyncCreate<TType, TCreateResponse>(providers, entity, true, (TCreateResponse)GetResponseType(RequestedResponseType.Create, entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete company.
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <response code="200">Success</response>
|
||||
/// <response code="0">There was an error</response>
|
||||
[HttpDelete]
|
||||
[Route("{id}/")]
|
||||
public virtual async Task<Results<BadRequest<Error>, Ok>> Delete([FromServices][ModelBinder(Name = "id")] TType entity)
|
||||
{
|
||||
db.Remove(entity!);
|
||||
|
||||
return await db.ApiSaveChangesAsync(TypedResults.Ok());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update company.
|
||||
/// </summary>
|
||||
|
|
@ -125,6 +110,33 @@ namespace NejCommon.Controllers
|
|||
}
|
||||
}
|
||||
[ApiController]
|
||||
public abstract class AutoGetterDeleteController<TOwner, TType, TGetAllResponse, TGetResponse> : AutoGetterController<TOwner, TType, TGetAllResponse, TGetResponse>
|
||||
where TType : class
|
||||
where TGetAllResponse : IAutomappedAttribute<TType, TGetAllResponse>, new()
|
||||
where TGetResponse : IAutomappedAttribute<TType, TGetResponse>, new()
|
||||
{
|
||||
public AutoGetterDeleteController(CommonDbContext appDb, IServiceProvider providers) : base(appDb, providers)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete company.
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <response code="200">Success</response>
|
||||
/// <response code="0">There was an error</response>
|
||||
[HttpDelete]
|
||||
[Route("{id}/")]
|
||||
public virtual async Task<Results<BadRequest<Error>, Ok>> Delete([FromServices][ModelBinder(Name = "id")] TType entity)
|
||||
{
|
||||
db.Remove(entity!);
|
||||
|
||||
return await db.ApiSaveChangesAsync(TypedResults.Ok());
|
||||
}
|
||||
}
|
||||
[ApiController]
|
||||
public abstract class AutoGetterController<TOwner, TType, TGetAllResponse, TGetResponse> : ControllerBase
|
||||
where TType : class
|
||||
where TGetAllResponse : IAutomappedAttribute<TType, TGetAllResponse>, new()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user