コード例 #1
0
        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);
        }
コード例 #2
0
 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));
     }
 }