public async Task <ActionResult> DeleteCollaborator([FromQuery] CollaboratorIdViewModel collaborator) { var model = await _collaboratorService.GetByIdAsync(collaborator); if (model == null) { return(NotFound()); } var result = await _collaboratorService.Remove(collaborator); if (result == null) { return(NotFound()); } var deleteUser = await _userService.DeleteUserAsync(model.Email); if (!deleteUser == true) { return(BadRequest()); } return(NoContent()); }
public async Task <CollaboratorViewModel> Remove(CollaboratorIdViewModel collaboratorIdViewModel) { var model = await _collaboratorRepository.GetByIdAsync(collaboratorIdViewModel.Id); if (model == null) { throw new Exception("Collaborator not found!"); } model.ClosingDate = DateTime.Now; var validation = new CollaboratorDeleteValidation().Validate(model); if (!validation.IsValid) { return(null); } _collaboratorRepository.Update(model); _unitOfWork.Commit(); var viewModel = _mapper.Map <CollaboratorViewModel>(model); return(viewModel); }
public async Task <ActionResult <CollaboratorViewModel> > GetById([FromQuery] CollaboratorIdViewModel collaborator) { var vm = await _collaboratorService.GetByIdAsync(collaborator); if (vm == null) { return(NotFound()); } return(Ok(vm)); }
public async Task <CollaboratorViewModel> GetByIdAsync(CollaboratorIdViewModel collaboratorIdViewModel) { return(_mapper.Map <CollaboratorViewModel>(await _collaboratorRepository.GetByIdAsync(collaboratorIdViewModel.Id))); }