public IHttpActionResult DeleteProfession(int id) { try { UnitOfWork unitOfWork = new UnitOfWork(factory); Profession profession = unitOfWork.ProfessionsRepository .Get(d => d.Id == id, includeProperties: "Country") .FirstOrDefault(); profession.Deleted = true; unitOfWork.ProfessionsRepository.Update(profession); unitOfWork.Save(); ProfessionDTO dto = profession.ToDTO(); return(Ok(dto)); } catch (NotFoundException nfe) { return(NotFound()); } catch (ConflictException ce) { return(Conflict()); } catch (Exception e) { return(BadRequest(e.Message)); } }