...
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using Common.Dtos.Company;
|
||||
using Hushian.Application.Constants;
|
||||
using Hushian.Application.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Hushian.WebApi.Controllers.v1
|
||||
{
|
||||
[Route("api/v1/[controller]")]
|
||||
[ApiController]
|
||||
public class CompanyController : ControllerBase
|
||||
{
|
||||
private readonly CompanyService _companyService;
|
||||
|
||||
public CompanyController(CompanyService companyService)
|
||||
{
|
||||
_companyService = companyService;
|
||||
}
|
||||
|
||||
[HttpPost("NewCompany")]
|
||||
public async Task<ActionResult<int>> NewCompany([FromBody] RegisterCompanyDto request)
|
||||
{
|
||||
var response = await _companyService.RegisterCompany(request);
|
||||
return response.Success ? Ok(response.Value)
|
||||
: BadRequest(response.Errors);
|
||||
}
|
||||
[HttpGet("GetCompany/{CompanyID}")]
|
||||
public async Task<ActionResult<ReadANDUpdate_CompanyDto>> GetCompany(int CompanyID)
|
||||
{
|
||||
var response = await _companyService.GETCompanyinformation(CompanyID);
|
||||
return response!=null ? Ok(response): NotFound();
|
||||
}
|
||||
[HttpPut("UpdateCompany")]
|
||||
[Authorize(Roles = "Company")]
|
||||
public async Task<ActionResult> UpdateCompany([FromBody] ReadANDUpdate_CompanyDto model)
|
||||
{
|
||||
string CompanyID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
|
||||
var response = await _companyService.EditCompany(model,Convert.ToInt32(CompanyID));
|
||||
return response.Success && response.Value ? NoContent()
|
||||
: BadRequest(response.Errors);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user