public async Task <Result> DeleteDeveloperAsync(Guid id) { var existDeveloper = await _developerRepository.ExistAsync(id); if (!existDeveloper) { return(new Result(Status.NotFund, $"Developer with {nameof(id)} does not exist")); } var developer = await _developerRepository.GetByIdAsync(id); await _developerRepository.DeleteAsync(developer); return(new Result()); }
public async Task GetByIdAsync() { var item1 = await DeveloperEntityFramework.AddAsync(builder.CreateDeveloper()); var result = await DeveloperEntityFramework.GetByIdAsync(item1.Id); Assert.AreEqual(result.Id, item1.Id); }
private void ValidateDeveloperId() { var dev = _developerRepository.GetByIdAsync(_appointment.DeveloperId).Result; if (dev == null || dev.Id == Guid.Empty) { throw new Exception("Este Desenvolvedor inválido."); } }
public async Task <GetDeveloperQueryHandlerResponse> Handle (GetDeveloperQuery request, CancellationToken cancellationToken) { Developer d = null; if (request.DeveloperUniqueId != null) { if (request.queryWitchDataBase == QueryWitchDataBase.WithEventSourcing) { d = await _zEsRepository.GetByIdAsync(request.DeveloperUniqueId); } else { d = await _Repository.GetByIdAsync(request.DeveloperUniqueId); } } else if (request.DeveloperId != null) { if (request.queryWitchDataBase == QueryWitchDataBase.WithEventSourcing) { d = await _zEsRepository.GetByIdAsync(request.DeveloperId); } else { d = await _Repository.GetByIdAsync(request.DeveloperId); } } else { return(new GetDeveloperQueryHandlerResponse(ResponseStatus.BadQuery)); } if (d == null) { return (new GetDeveloperQueryHandlerResponse(ResponseStatus.NotFoundInDataBase)); } var dMaped = _mapper.Map <DeveloperViewModel>(d); return(new GetDeveloperQueryHandlerResponse(dMaped)); }
public async Task <GenericCommandResult> GetById(Guid id) { var data = await _developerRepository.GetByIdAsync(id); if (data == null) { return(new GenericCommandResult(false, "Desenvolvedor não encontrado")); } return(new GenericCommandResult(true, "Desenvolvedor retornado com sucesso", data)); }
public async Task <ICommandResult> Handle(UpdateDeveloperCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Operação inválida", command.Notifications)); } var developerDb = await _developerRepository.GetByIdAsync(command.Id); if (developerDb == null) { return(new GenericCommandResult(false, "Desenvolvedor não encontrado", command.Notifications)); } _mapper.Map(command, developerDb); await _developerRepository.UpdateAsync(developerDb); return(new GenericCommandResult(true, "Desenvolvedor alterado com sucesso", developerDb)); }
public async Task <ICommandResult> Handle(AddDeveloperInProjectCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Operação inválida", command.Notifications)); } var projectDb = await _projectRepository.GetProjectWithDevelopersProject(command.ProjectId); if (projectDb == null) { return(new GenericCommandResult(false, "Projeto não encontrado", command.Notifications)); } var developerDb = await _developerRepository.GetByIdAsync(command.DeveloperId); if (developerDb == null) { return(new GenericCommandResult(false, "Desenvolvedor não encontrado", command.Notifications)); } var developerProject = new DeveloperProject { Project = projectDb, Developer = developerDb }; projectDb.DeveloperProjects.Add(developerProject); await _projectRepository.UpdateAsync(projectDb); return(new GenericCommandResult(true, "Desenvolvedor adicionado ao projeto com sucesso", new { DeveloperName = developerDb.Name, ProjectName = projectDb.Name })); }
public async Task <RejectDeveloperCommandResponse> Handle (RejectDeveloperCommand request, CancellationToken cancellationToken) { var developerUniqueId = _mapper.Map <DeveloperUniqueId> (request.DeveloperUniqueId); var developer = await _callRepository.GetByIdAsync(developerUniqueId); if (developer.Status == DeveloperStatus.New) { await _callRepository.SaveRejectionAsync (developerUniqueId); } else { return(new RejectDeveloperCommandResponse("Can't Reject Developer " + "that is alread " + developer.Status.ToString(), false)); } return(new RejectDeveloperCommandResponse()); }
public Task <Developer> GetById(int id) { return(_developerRepository.GetByIdAsync(id)); }
public async Task <DeveloperViewModel> GetById(Guid id) { return(_mapper.Map <DeveloperViewModel>(await _developerRepository.GetByIdAsync(id))); }
public async Task DeleteDeveloper(int id) { var entity = await _repository.GetByIdAsync(id); _repository.Delete(entity); }