aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Services/Services/TechnologyService.cs
diff options
context:
space:
mode:
authorKamen Mladenov <kamen.d.mladenov@protonmail.com>2021-04-09 19:51:35 +0300
committerGitHub <noreply@github.com>2021-04-09 19:51:35 +0300
commit233f38915ba0079079233eff55434ef349c05c45 (patch)
tree6c5f69017865bcab87355e910c87339453da1406 /src/DevHive.Services/Services/TechnologyService.cs
parentf4a70c6430db923af9fa9958a11c2d6612cb52cc (diff)
parenta992357efcf1bc1ece81b95ecee5e05a0b73bfdc (diff)
downloadDevHive-233f38915ba0079079233eff55434ef349c05c45.tar
DevHive-233f38915ba0079079233eff55434ef349c05c45.tar.gz
DevHive-233f38915ba0079079233eff55434ef349c05c45.zip
Merge pull request #28 from Team-Kaleidoscope/devHEADv0.2mainheroku/main
Second stage: Complete
Diffstat (limited to 'src/DevHive.Services/Services/TechnologyService.cs')
-rw-r--r--src/DevHive.Services/Services/TechnologyService.cs90
1 files changed, 0 insertions, 90 deletions
diff --git a/src/DevHive.Services/Services/TechnologyService.cs b/src/DevHive.Services/Services/TechnologyService.cs
deleted file mode 100644
index 6dd6286..0000000
--- a/src/DevHive.Services/Services/TechnologyService.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using AutoMapper;
-using DevHive.Data.Interfaces.Repositories;
-using DevHive.Data.Models;
-using DevHive.Services.Interfaces;
-using DevHive.Services.Models.Technology;
-
-namespace DevHive.Services.Services
-{
- public class TechnologyService : ITechnologyService
- {
- private readonly ITechnologyRepository _technologyRepository;
- private readonly IMapper _technologyMapper;
-
- public TechnologyService(ITechnologyRepository technologyRepository, IMapper technologyMapper)
- {
- this._technologyRepository = technologyRepository;
- this._technologyMapper = technologyMapper;
- }
-
- #region Create
- public async Task<Guid> CreateTechnology(CreateTechnologyServiceModel technologyServiceModel)
- {
- if (await this._technologyRepository.DoesTechnologyNameExistAsync(technologyServiceModel.Name))
- throw new ArgumentException("Technology already exists!");
-
- Technology technology = this._technologyMapper.Map<Technology>(technologyServiceModel);
- bool success = await this._technologyRepository.AddAsync(technology);
-
- if (success)
- {
- Technology newTechnology = await this._technologyRepository.GetByNameAsync(technologyServiceModel.Name);
- return newTechnology.Id;
- }
- else
- return Guid.Empty;
- }
- #endregion
-
- #region Read
- public async Task<ReadTechnologyServiceModel> GetTechnologyById(Guid id)
- {
- Technology technology = await this._technologyRepository.GetByIdAsync(id);
-
- if (technology == null)
- throw new ArgumentException("The technology does not exist");
-
- return this._technologyMapper.Map<ReadTechnologyServiceModel>(technology);
- }
-
- public HashSet<ReadTechnologyServiceModel> GetTechnologies()
- {
- HashSet<Technology> technologies = this._technologyRepository.GetTechnologies();
-
- return this._technologyMapper.Map<HashSet<ReadTechnologyServiceModel>>(technologies);
- }
- #endregion
-
- #region Update
- public async Task<bool> UpdateTechnology(UpdateTechnologyServiceModel updateTechnologyServiceModel)
- {
- if (!await this._technologyRepository.DoesTechnologyExistAsync(updateTechnologyServiceModel.Id))
- throw new ArgumentException("Technology does not exist!");
-
- if (await this._technologyRepository.DoesTechnologyNameExistAsync(updateTechnologyServiceModel.Name))
- throw new ArgumentException("Technology name already exists!");
-
- Technology technology = this._technologyMapper.Map<Technology>(updateTechnologyServiceModel);
- bool result = await this._technologyRepository.EditAsync(updateTechnologyServiceModel.Id, technology);
-
- return result;
- }
- #endregion
-
- #region Delete
- public async Task<bool> DeleteTechnology(Guid id)
- {
- if (!await this._technologyRepository.DoesTechnologyExistAsync(id))
- throw new ArgumentException("Technology does not exist!");
-
- Technology technology = await this._technologyRepository.GetByIdAsync(id);
- bool result = await this._technologyRepository.DeleteAsync(technology);
-
- return result;
- }
- #endregion
- }
-}