From 98e17766b203734a1817eed94338e2d25f4395f7 Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 13 Feb 2021 16:20:18 +0200 Subject: Project Restructure P.1 --- src/DevHive.Services/Services/TechnologyService.cs | 90 ---------------------- 1 file changed, 90 deletions(-) delete mode 100644 src/DevHive.Services/Services/TechnologyService.cs (limited to 'src/DevHive.Services/Services/TechnologyService.cs') 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 CreateTechnology(CreateTechnologyServiceModel technologyServiceModel) - { - if (await this._technologyRepository.DoesTechnologyNameExistAsync(technologyServiceModel.Name)) - throw new ArgumentException("Technology already exists!"); - - Technology technology = this._technologyMapper.Map(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 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(technology); - } - - public HashSet GetTechnologies() - { - HashSet technologies = this._technologyRepository.GetTechnologies(); - - return this._technologyMapper.Map>(technologies); - } - #endregion - - #region Update - public async Task 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(updateTechnologyServiceModel); - bool result = await this._technologyRepository.EditAsync(updateTechnologyServiceModel.Id, technology); - - return result; - } - #endregion - - #region Delete - public async Task 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 - } -} -- cgit v1.2.3