diff options
| author | transtrike <transtrike@gmail.com> | 2021-01-21 22:13:16 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-01-21 22:13:16 +0200 |
| commit | 13a2ceda912f961a232c87236f1b29aa29bb6160 (patch) | |
| tree | 59f8d2bf63b03bacc76f98114d2aed78e420ddcd /src/DevHive.Web/Controllers/TechnologyController.cs | |
| parent | a47ea20ab91017da53437f750ed8e0f939f5cdba (diff) | |
| parent | bda98b96433d7a9952524fab4ec65f96998b55de (diff) | |
| download | DevHive-13a2ceda912f961a232c87236f1b29aa29bb6160.tar DevHive-13a2ceda912f961a232c87236f1b29aa29bb6160.tar.gz DevHive-13a2ceda912f961a232c87236f1b29aa29bb6160.zip | |
Merge branch 'refactor_user_updating' into dev
Diffstat (limited to 'src/DevHive.Web/Controllers/TechnologyController.cs')
| -rw-r--r-- | src/DevHive.Web/Controllers/TechnologyController.cs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/DevHive.Web/Controllers/TechnologyController.cs b/src/DevHive.Web/Controllers/TechnologyController.cs index 3be3b8a..ba2ffdc 100644 --- a/src/DevHive.Web/Controllers/TechnologyController.cs +++ b/src/DevHive.Web/Controllers/TechnologyController.cs @@ -22,33 +22,33 @@ namespace DevHive.Web.Controllers } [HttpPost] - public async Task<IActionResult> Create([FromBody] CreateTechnologyWebModel technologyWebModel) + public async Task<IActionResult> Create([FromBody] CreateTechnologyWebModel createTechnologyWebModel) { - CreateTechnologyServiceModel technologyServiceModel = this._technologyMapper.Map<CreateTechnologyServiceModel>(technologyWebModel); + CreateTechnologyServiceModel technologyServiceModel = this._technologyMapper.Map<CreateTechnologyServiceModel>(createTechnologyWebModel); - bool result = await this._technologyService.Create(technologyServiceModel); + Guid id = await this._technologyService.Create(technologyServiceModel); - if (!result) - return new BadRequestObjectResult("Could not create the Technology"); - - return new OkResult(); + return id == Guid.Empty ? + new BadRequestObjectResult($"Could not create technology {createTechnologyWebModel.Name}") : + new OkObjectResult(new { Id = id }); } [HttpGet] - public async Task<IActionResult> GetById(Guid technologyId) + public async Task<IActionResult> GetById(Guid id) { - CreateTechnologyServiceModel createTechnologyServiceModel = await this._technologyService.GetTechnologyById(technologyId); + CreateTechnologyServiceModel createTechnologyServiceModel = await this._technologyService.GetTechnologyById(id); CreateTechnologyWebModel createTechnologyWebModel = this._technologyMapper.Map<CreateTechnologyWebModel>(createTechnologyServiceModel); return new OkObjectResult(createTechnologyWebModel); } [HttpPut] - public async Task<IActionResult> Update(Guid technologyId, [FromBody] UpdateTechnologyWebModel updateModel) + public async Task<IActionResult> Update(Guid id, [FromBody] UpdateTechnologyWebModel updateModel) { - UpdateTechnologyServiceModel updateTechnologyWebModel = this._technologyMapper.Map<UpdateTechnologyServiceModel>(updateModel); + UpdateTechnologyServiceModel updateTechnologyServiceModel = this._technologyMapper.Map<UpdateTechnologyServiceModel>(updateModel); + updateTechnologyServiceModel.Id = id; - bool result = await this._technologyService.UpdateTechnology(technologyId, updateTechnologyWebModel); + bool result = await this._technologyService.UpdateTechnology(updateTechnologyServiceModel); if (!result) return new BadRequestObjectResult("Could not update Technology"); @@ -57,9 +57,9 @@ namespace DevHive.Web.Controllers } [HttpDelete] - public async Task<IActionResult> Delete(Guid technologyId) + public async Task<IActionResult> Delete(Guid id) { - bool result = await this._technologyService.DeleteTechnology(technologyId); + bool result = await this._technologyService.DeleteTechnology(id); if (!result) return new BadRequestObjectResult("Could not delete Technology"); |
