Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/API/Grand.Api/Controllers/BaseODataController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Grand.Api.Filters;
using Microsoft.AspNet.OData;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Routing.Attributes;
using Microsoft.AspNetCore.OData.Routing.Controllers;

namespace Grand.Api.Controllers
{
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[ODataRouteComponent]
[Route("odata/[controller]")]
[ApiExplorerSettings(IgnoreApi = false)]
[AuthorizeApiAdmin]
Expand Down
28 changes: 15 additions & 13 deletions src/API/Grand.Api/Controllers/OData/BrandController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -24,6 +24,17 @@ public BrandController(IMediator mediator, IPermissionService permissionService)
_permissionService = permissionService;
}

[SwaggerOperation(summary: "Get entities from Brand", OperationId = "GetBrands")]
[HttpGet]
[EnableQuery]
public async Task<IActionResult> Get()
{
if (!await _permissionService.Authorize(PermissionSystemName.Brands))
return Forbid();

return Ok(await _mediator.Send(new GetQuery<BrandDto>()));
}

[SwaggerOperation(summary: "Get entity from Brand by key", OperationId = "GetBrandById")]
[HttpGet("{key}")]
public async Task<IActionResult> Get(string key)
Expand All @@ -38,16 +49,7 @@ public async Task<IActionResult> Get(string key)
return Ok(brand);
}

[SwaggerOperation(summary: "Get entities from Brand", OperationId = "GetBrands")]
[HttpGet]
[EnableQuery(HandleNullPropagation = HandleNullPropagationOption.False)]
public async Task<IActionResult> Get()
{
if (!await _permissionService.Authorize(PermissionSystemName.Brands))
return Forbid();

return Ok(await _mediator.Send(new GetQuery<BrandDto>()));
}


[SwaggerOperation(summary: "Add new entity to Brand", OperationId = "InsertBrand")]
[HttpPost]
Expand All @@ -59,7 +61,7 @@ public async Task<IActionResult> Post([FromBody] BrandDto model)
if (ModelState.IsValid)
{
model = await _mediator.Send(new AddBrandCommand() { Model = model });
return Created(model);
return Ok(model);
}
return BadRequest(ModelState);
}
Expand Down
3 changes: 1 addition & 2 deletions src/API/Grand.Api/Controllers/OData/BrandLayoutController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
6 changes: 3 additions & 3 deletions src/API/Grand.Api/Controllers/OData/CategoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -61,7 +61,7 @@ public async Task<IActionResult> Post([FromBody] CategoryDto model)
if (ModelState.IsValid)
{
model = await _mediator.Send(new AddCategoryCommand() { Model = model });
return Created(model);
return Ok(model);
}
return BadRequest(ModelState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
6 changes: 3 additions & 3 deletions src/API/Grand.Api/Controllers/OData/CollectionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -59,7 +59,7 @@ public async Task<IActionResult> Post([FromBody] CollectionDto model)
if (ModelState.IsValid)
{
model = await _mediator.Send(new AddCollectionCommand() { Model = model });
return Created(model);
return Ok(model);
}
return BadRequest(ModelState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
3 changes: 1 addition & 2 deletions src/API/Grand.Api/Controllers/OData/CountryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
3 changes: 1 addition & 2 deletions src/API/Grand.Api/Controllers/OData/CurrencyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
6 changes: 3 additions & 3 deletions src/API/Grand.Api/Controllers/OData/CustomerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using Grand.Business.Customers.Utilities;
using Grand.Domain.Customers;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -59,7 +59,7 @@ public async Task<IActionResult> Post([FromBody] CustomerDto model)
if (ModelState.IsValid)
{
model = await _mediator.Send(new AddCustomerCommand() { Model = model });
return Created(model);
return Ok(model);
}
return BadRequest(ModelState);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public async Task<IActionResult> Delete(string key)

//odata/Customer(email)/AddAddress
[SwaggerOperation(summary: "Invoke action AddAddress", OperationId = "AddAddress")]
[Route("({key}/[action]")]
[Route("({key})/[action]")]
[HttpPost]
public async Task<IActionResult> AddAddress(string key, [FromBody] AddressDto address)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -60,7 +60,7 @@ public async Task<IActionResult> Post([FromBody] CustomerGroupDto model)
if (ModelState.IsValid)
{
model = await _mediator.Send(new AddCustomerGroupCommand() { Model = model });
return Created(model);
return Ok(model);
}
return BadRequest(ModelState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
3 changes: 1 addition & 2 deletions src/API/Grand.Api/Controllers/OData/LanguageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
3 changes: 1 addition & 2 deletions src/API/Grand.Api/Controllers/OData/PickupPointController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
2 changes: 1 addition & 1 deletion src/API/Grand.Api/Controllers/OData/PictureController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task<IActionResult> Post([FromBody] PictureDto model)
if (ModelState.IsValid)
{
model = await _mediator.Send(new AddPictureCommand() { PictureDto = model });
return Created(model);
return Ok(model);
}
return BadRequest(ModelState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -62,7 +62,7 @@ public async Task<IActionResult> Post([FromBody] ProductAttributeDto model)
if (ModelState.IsValid)
{
model = await _mediator.Send(new AddProductAttributeCommand() { Model = model });
return Created(model);
return Ok(model);
}
return BadRequest(ModelState);
}
Expand Down
8 changes: 4 additions & 4 deletions src/API/Grand.Api/Controllers/OData/ProductController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -62,7 +62,7 @@ public async Task<IActionResult> Post([FromBody] ProductDto model)
if (ModelState.IsValid)
{
model = await _mediator.Send(new AddProductCommand() { Model = model });
return Created(model);
return Ok(model);
}
return BadRequest(ModelState);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ public async Task<IActionResult> Delete(string key)
return Ok();
}

//odata/Product(id)/UpdateStock
//odata/Product/(id)/UpdateStock
//body: { "Stock": 10 }
[SwaggerOperation(summary: "Invoke action UpdateStock", OperationId = "UpdateStock")]
[Route("({key})/[action]")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.JsonPatch;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -59,7 +59,7 @@ public async Task<IActionResult> Post([FromBody] SpecificationAttributeDto model
if (ModelState.IsValid)
{
model = await _mediator.Send(new AddSpecificationAttributeCommand() { Model = model });
return Created(model);
return Ok(model);
}
return BadRequest(ModelState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
3 changes: 1 addition & 2 deletions src/API/Grand.Api/Controllers/OData/StoreController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
3 changes: 1 addition & 2 deletions src/API/Grand.Api/Controllers/OData/VendorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using Grand.Business.Common.Interfaces.Security;
using Grand.Business.Common.Services.Security;
using MediatR;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Query;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
using System.Threading.Tasks;
Expand Down
Loading