aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/DevHive.Services/Interfaces/ILanguageService.cs10
-rw-r--r--src/DevHive.Services/Interfaces/ITechnologyService.cs6
-rw-r--r--src/DevHive.Services/Services/LanguageService.cs27
-rw-r--r--src/DevHive.Services/Services/TechnologyService.cs15
-rw-r--r--src/DevHive.Web/Controllers/LanguageController.cs13
-rw-r--r--src/DevHive.Web/Controllers/TechnologyController.cs12
6 files changed, 41 insertions, 42 deletions
diff --git a/src/DevHive.Services/Interfaces/ILanguageService.cs b/src/DevHive.Services/Interfaces/ILanguageService.cs
index f62bce7..eb45a8d 100644
--- a/src/DevHive.Services/Interfaces/ILanguageService.cs
+++ b/src/DevHive.Services/Interfaces/ILanguageService.cs
@@ -8,10 +8,10 @@ namespace DevHive.Services.Interfaces
{
Task<bool> CreateLanguage(CreateLanguageServiceModel createLanguageServiceModel);
- Task<LanguageServiceModel> GetLanguageById(Guid id);
+ Task<LanguageServiceModel> GetLanguageById(Guid languageId);
- Task<bool> UpdateLanguage(UpdateLanguageServiceModel languageServiceModel);
-
- Task<bool> DeleteLanguage(Guid id);
+ Task<bool> UpdateLanguage(Guid languageId, UpdateLanguageServiceModel languageServiceModel);
+
+ Task<bool> DeleteLanguage(Guid languageId);
}
-} \ No newline at end of file
+}
diff --git a/src/DevHive.Services/Interfaces/ITechnologyService.cs b/src/DevHive.Services/Interfaces/ITechnologyService.cs
index 33032e2..f0dfaca 100644
--- a/src/DevHive.Services/Interfaces/ITechnologyService.cs
+++ b/src/DevHive.Services/Interfaces/ITechnologyService.cs
@@ -10,8 +10,8 @@ namespace DevHive.Services.Interfaces
Task<TechnologyServiceModel> GetTechnologyById(Guid id);
- Task<bool> UpdateTechnology(UpdateTechnologyServiceModel updateTechnologyServiceModel);
-
+ Task<bool> UpdateTechnology(Guid technologyId, UpdateTechnologyServiceModel updateTechnologyServiceModel);
+
Task<bool> DeleteTechnology(Guid id);
}
-} \ No newline at end of file
+}
diff --git a/src/DevHive.Services/Services/LanguageService.cs b/src/DevHive.Services/Services/LanguageService.cs
index ac7652b..c34537f 100644
--- a/src/DevHive.Services/Services/LanguageService.cs
+++ b/src/DevHive.Services/Services/LanguageService.cs
@@ -35,9 +35,9 @@ namespace DevHive.Services.Services
#region Read
- public async Task<LanguageServiceModel> GetLanguageById(Guid id)
+ public async Task<LanguageServiceModel> GetLanguageById(Guid languageId)
{
- Language language = await this._languageRepository.GetByIdAsync(id);
+ Language language = await this._languageRepository.GetByIdAsync(languageId);
if (language == null)
throw new ArgumentException("The language does not exist");
@@ -48,19 +48,18 @@ namespace DevHive.Services.Services
#region Update
- public async Task<bool> UpdateLanguage(UpdateLanguageServiceModel languageServiceModel)
+ public async Task<bool> UpdateLanguage(Guid languageId, UpdateLanguageServiceModel languageServiceModel)
{
- Task<bool> langExist = this._languageRepository.DoesLanguageExistAsync(languageServiceModel.Id);
- Task<bool> newLangNameExists = this._languageRepository.DoesLanguageNameExistAsync(languageServiceModel.Name);
+ bool langExists = await this._languageRepository.DoesLanguageExistAsync(languageId);
+ bool newLangNameExists = await this._languageRepository.DoesLanguageNameExistAsync(languageServiceModel.Name);
- await Task.WhenAny(langExist, newLangNameExists);
-
- if (!langExist.Result)
- throw new ArgumentException("Language already exists!");
+ if (!langExists)
+ throw new ArgumentException("Language does not exist!");
- if (newLangNameExists.Result)
+ if (newLangNameExists)
throw new ArgumentException("This name is already in our datbase!");
+ languageServiceModel.Id = languageId;
Language lang = this._languageMapper.Map<Language>(languageServiceModel);
return await this._languageRepository.EditAsync(lang);
}
@@ -68,14 +67,14 @@ namespace DevHive.Services.Services
#region Delete
- public async Task<bool> DeleteLanguage(Guid id)
+ public async Task<bool> DeleteLanguage(Guid languageId)
{
- if (!await this._languageRepository.DoesLanguageExistAsync(id))
+ if (!await this._languageRepository.DoesLanguageExistAsync(languageId))
throw new ArgumentException("Language does not exist!");
- Language language = await this._languageRepository.GetByIdAsync(id);
+ Language language = await this._languageRepository.GetByIdAsync(languageId);
return await this._languageRepository.DeleteAsync(language);
}
#endregion
}
-} \ No newline at end of file
+}
diff --git a/src/DevHive.Services/Services/TechnologyService.cs b/src/DevHive.Services/Services/TechnologyService.cs
index 2b24ed6..3cc0861 100644
--- a/src/DevHive.Services/Services/TechnologyService.cs
+++ b/src/DevHive.Services/Services/TechnologyService.cs
@@ -35,9 +35,9 @@ namespace DevHive.Services.Services
#region Read
- public async Task<TechnologyServiceModel> GetTechnologyById(Guid id)
+ public async Task<TechnologyServiceModel> GetTechnologyById(Guid technologyId)
{
- Technology technology = await this._technologyRepository.GetByIdAsync(id);
+ Technology technology = await this._technologyRepository.GetByIdAsync(technologyId);
if (technology == null)
throw new ArgumentException("The technology does not exist");
@@ -48,14 +48,15 @@ namespace DevHive.Services.Services
#region Update
- public async Task<bool> UpdateTechnology(UpdateTechnologyServiceModel updateTechnologyServiceModel)
+ public async Task<bool> UpdateTechnology(Guid technologyId, UpdateTechnologyServiceModel updateTechnologyServiceModel)
{
- if (!await this._technologyRepository.DoesTechnologyExistAsync(updateTechnologyServiceModel.Id))
+ if (!await this._technologyRepository.DoesTechnologyExistAsync(technologyId))
throw new ArgumentException("Technology does not exist!");
if (await this._technologyRepository.DoesTechnologyNameExistAsync(updateTechnologyServiceModel.Name))
throw new ArgumentException("Technology name already exists!");
+ updateTechnologyServiceModel.Id = technologyId;
Technology technology = this._technologyMapper.Map<Technology>(updateTechnologyServiceModel);
bool result = await this._technologyRepository.EditAsync(technology);
@@ -65,12 +66,12 @@ namespace DevHive.Services.Services
#region Delete
- public async Task<bool> DeleteTechnology(Guid id)
+ public async Task<bool> DeleteTechnology(Guid technologyId)
{
- if (!await this._technologyRepository.DoesTechnologyExistAsync(id))
+ if (!await this._technologyRepository.DoesTechnologyExistAsync(technologyId))
throw new ArgumentException("Technology does not exist!");
- Technology technology = await this._technologyRepository.GetByIdAsync(id);
+ Technology technology = await this._technologyRepository.GetByIdAsync(technologyId);
bool result = await this._technologyRepository.DeleteAsync(technology);
return result;
diff --git a/src/DevHive.Web/Controllers/LanguageController.cs b/src/DevHive.Web/Controllers/LanguageController.cs
index 486e16e..5e1a9a7 100644
--- a/src/DevHive.Web/Controllers/LanguageController.cs
+++ b/src/DevHive.Web/Controllers/LanguageController.cs
@@ -36,21 +36,20 @@ namespace DevHive.Web.Controllers
}
[HttpGet]
- public async Task<IActionResult> GetById(Guid id)
+ public async Task<IActionResult> GetById(Guid languageId)
{
- LanguageServiceModel languageServiceModel = await this._languageService.GetLanguageById(id);
+ LanguageServiceModel languageServiceModel = await this._languageService.GetLanguageById(languageId);
LanguageWebModel languageWebModel = this._languageMapper.Map<LanguageWebModel>(languageServiceModel);
return new OkObjectResult(languageWebModel);
}
[HttpPut]
- public async Task<IActionResult> Update(Guid id, [FromBody] UpdateLanguageWebModel updateModel)
+ public async Task<IActionResult> Update(Guid languageId, [FromBody] UpdateLanguageWebModel updateModel)
{
UpdateLanguageServiceModel updatelanguageServiceModel = this._languageMapper.Map<UpdateLanguageServiceModel>(updateModel);
- updatelanguageServiceModel.Id = id;
- bool result = await this._languageService.UpdateLanguage(updatelanguageServiceModel);
+ bool result = await this._languageService.UpdateLanguage(languageId, updatelanguageServiceModel);
if (!result)
return new BadRequestObjectResult("Could not update Language");
@@ -59,9 +58,9 @@ namespace DevHive.Web.Controllers
}
[HttpDelete]
- public async Task<IActionResult> Delete(Guid id)
+ public async Task<IActionResult> Delete(Guid languageId)
{
- bool result = await this._languageService.DeleteLanguage(id);
+ bool result = await this._languageService.DeleteLanguage(languageId);
if (!result)
return new BadRequestObjectResult("Could not delete Language");
diff --git a/src/DevHive.Web/Controllers/TechnologyController.cs b/src/DevHive.Web/Controllers/TechnologyController.cs
index 905a71d..964bafc 100644
--- a/src/DevHive.Web/Controllers/TechnologyController.cs
+++ b/src/DevHive.Web/Controllers/TechnologyController.cs
@@ -36,20 +36,20 @@ namespace DevHive.Web.Controllers
}
[HttpGet]
- public async Task<IActionResult> GetById(Guid id)
+ public async Task<IActionResult> GetById(Guid technologyId)
{
- TechnologyServiceModel technologyServiceModel = await this._technologyService.GetTechnologyById(id);
+ TechnologyServiceModel technologyServiceModel = await this._technologyService.GetTechnologyById(technologyId);
TechnologyWebModel technologyWebModel = this._technologyMapper.Map<TechnologyWebModel>(technologyServiceModel);
return new OkObjectResult(technologyWebModel);
}
[HttpPut]
- public async Task<IActionResult> Update(Guid id, [FromBody] UpdateTechnologyWebModel updateModel)
+ public async Task<IActionResult> Update(Guid technologyId, [FromBody] UpdateTechnologyWebModel updateModel)
{
UpdateTechnologyServiceModel updateTechnologyWebModel = this._technologyMapper.Map<UpdateTechnologyServiceModel>(updateModel);
- bool result = await this._technologyService.UpdateTechnology(updateTechnologyWebModel);
+ bool result = await this._technologyService.UpdateTechnology(technologyId, updateTechnologyWebModel);
if (!result)
return new BadRequestObjectResult("Could not update Technology");
@@ -58,9 +58,9 @@ namespace DevHive.Web.Controllers
}
[HttpDelete]
- public async Task<IActionResult> Delete(Guid id)
+ public async Task<IActionResult> Delete(Guid technologyId)
{
- bool result = await this._technologyService.DeleteTechnology(id);
+ bool result = await this._technologyService.DeleteTechnology(technologyId);
if (!result)
return new BadRequestObjectResult("Could not delete Technology");