public async Task <AreaDto> AddArea(AreaDto request) { ValidationFields(request); if (request.ResponsableEmployedId == null || request.ResponsableEmployedId == default || request.AreaId == null || request.AreaId == default || request.AreaName == null || request.AreaName == default) { throw new EmployeedNotExistInArea(); } var employeeExistInAnArea = _areaRepo .SearchMatching <AreaEntity>(e => e.ResponsableEmployedId == request.ResponsableEmployedId); if (employeeExistInAnArea.Any()) { throw new TheEmployeedAlreadyIsInAnArea(); } var response = await _employeeRepo.Insert(_mapper.Map <AreaEntity>(request)).ConfigureAwait(false); return(_mapper.Map <AreaDto>(response)); }
public async Task <Guid> Insert(AreaRequestDto requestDto) { ValidationDto(requestDto); var usernameExist = _areaRepositorio .SearchMatching <AreaEntity>(x => x.NombreArea == requestDto.NombreArea) .Any(); if (usernameExist) { throw new AreanameAlreadyExistException(requestDto.NombreArea); } var response = await _areaRepositorio.Insert(_mapper.Map <AreaEntity>(requestDto)).ConfigureAwait(false); return(response.Id); }