public async Task <int> Add(RelationshipToSaveDto entity) { if (await _unitOfWork.Relationship.Exists(x => x.Description == entity.Description)) { throw new Exception("Already exists."); } Relationship Relationship = _mapper.Map <Relationship>(entity); _unitOfWork.Relationship.Add(Relationship); _unitOfWork.Complete(); return(Relationship.Id); }
public async Task <IActionResult> Post(RelationshipToSaveDto RelationshipDto) { try { if (await _serviceManager.Relationship.Add(RelationshipDto)) { return(StatusCode(201)); } else { return(BadRequest()); } } catch (System.Exception e) { return(HandleException(e)); } }