naming
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
// src/Webshop.Api/Controllers/Admin/AdmincategorysController.cs
|
||||
// src/Webshop.Api/Controllers/Admin/AdmincategoriesController.cs
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Categorys;
|
||||
using Webshop.Application.DTOs.categories;
|
||||
using Webshop.Application.Services.Admin;
|
||||
|
||||
namespace Webshop.Api.Controllers.Admin
|
||||
@@ -12,51 +12,51 @@ namespace Webshop.Api.Controllers.Admin
|
||||
[ApiController]
|
||||
[Route("api/v1/admin/[controller]")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public class AdminCategorysController : ControllerBase
|
||||
public class AdmincategoriesController : ControllerBase
|
||||
{
|
||||
private readonly IAdminCategoryService _adminCategoryService;
|
||||
private readonly IAdminCategorieService _admincategorieservice;
|
||||
|
||||
public AdminCategorysController(IAdminCategoryService adminCategoryService)
|
||||
public AdmincategoriesController(IAdminCategorieService admincategorieservice)
|
||||
{
|
||||
_adminCategoryService = adminCategoryService;
|
||||
_admincategorieservice = admincategorieservice;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<IEnumerable<CategoryDto>>> GetAllcategorys()
|
||||
public async Task<ActionResult<IEnumerable<categorieDto>>> GetAllcategories()
|
||||
{
|
||||
var categorys = await _adminCategoryService.GetAllAsync();
|
||||
return Ok(categorys);
|
||||
var categories = await _admincategorieservice.GetAllAsync();
|
||||
return Ok(categories);
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<ActionResult<CategoryDto>> GetCategoryById(Guid id)
|
||||
public async Task<ActionResult<categorieDto>> GetcategorieById(Guid id)
|
||||
{
|
||||
var category = await _adminCategoryService.GetByIdAsync(id);
|
||||
if (category == null) return NotFound();
|
||||
return Ok(category);
|
||||
var categorie = await _admincategorieservice.GetByIdAsync(id);
|
||||
if (categorie == null) return NotFound();
|
||||
return Ok(categorie);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<CategoryDto>> CreateCategory([FromBody] CreateCategoryDto categoryDto)
|
||||
public async Task<ActionResult<categorieDto>> Createcategorie([FromBody] CreatecategorieDto categorieDto)
|
||||
{
|
||||
if (!ModelState.IsValid) return BadRequest(ModelState);
|
||||
|
||||
var (createdCategory, errorMessage) = await _adminCategoryService.CreateAsync(categoryDto);
|
||||
var (createdcategorie, errorMessage) = await _admincategorieservice.CreateAsync(categorieDto);
|
||||
|
||||
if (createdCategory == null)
|
||||
if (createdcategorie == null)
|
||||
{
|
||||
return BadRequest(new { Message = errorMessage });
|
||||
}
|
||||
|
||||
return CreatedAtAction(nameof(GetCategoryById), new { id = createdCategory.Id }, createdCategory);
|
||||
return CreatedAtAction(nameof(GetcategorieById), new { id = createdcategorie.Id }, createdcategorie);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> UpdateCategory(Guid id, [FromBody] CreateCategoryDto categoryDto)
|
||||
public async Task<IActionResult> Updatecategorie(Guid id, [FromBody] CreatecategorieDto categorieDto)
|
||||
{
|
||||
if (!ModelState.IsValid) return BadRequest(ModelState);
|
||||
|
||||
var (success, errorMessage) = await _adminCategoryService.UpdateAsync(id, categoryDto);
|
||||
var (success, errorMessage) = await _admincategorieservice.UpdateAsync(id, categorieDto);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
@@ -67,9 +67,9 @@ namespace Webshop.Api.Controllers.Admin
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteCategory(Guid id)
|
||||
public async Task<IActionResult> Deletecategorie(Guid id)
|
||||
{
|
||||
var success = await _adminCategoryService.DeleteAsync(id);
|
||||
var success = await _admincategorieservice.DeleteAsync(id);
|
||||
if (!success) return NotFound();
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user