示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
        public async Task <ActionResult <CollaboratorViewModel> > GetById([FromQuery] CollaboratorIdViewModel collaborator)
        {
            var vm = await _collaboratorService.GetByIdAsync(collaborator);

            if (vm == null)
            {
                return(NotFound());
            }

            return(Ok(vm));
        }
示例#4
0
 public async Task <CollaboratorViewModel> GetByIdAsync(CollaboratorIdViewModel collaboratorIdViewModel)
 {
     return(_mapper.Map <CollaboratorViewModel>(await _collaboratorRepository.GetByIdAsync(collaboratorIdViewModel.Id)));
 }