Beispiel #1
0
        public IActionResult DeleteConsultant(long id)
        {
            Consultant a = con_repo.Find(id);

            if (a == null)
            {
                return(NotFound());
            }
            con_repo.Delete(a);
            return(Ok());
        }
Beispiel #2
0
        public async Task <ConsultantResponse> DeleteAsync(Consultant consultant)
        {
            if (_consultantRepository.GetById(consultant.ID) == null)
            {
                return(new ConsultantResponse("Object With Specific ID Was Null"));
            }

            try
            {
                _consultantRepository.Delete(consultant);
                await _unitOfWork.CompleteAsync();

                return(new ConsultantResponse(consultant));
            }
            catch (Exception ex)
            {
                // Do some logging stuff
                return(new ConsultantResponse($"An error occurred when deleting the Consultant: {ex.Message}"));
            }
        }
Beispiel #3
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                Competence result = await repository.GetCompetenceAsync(id);

                if (result == null)
                {
                    return(NotFound());
                }
                repository.Delete(result);
                if (await repository.SaveChangesAsync())
                {
                    return(Ok());
                }
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Error in database"));
            }
            return(BadRequest("Failed to delete the competence"));
        }