コード例 #1
0
 public IActionResult AssociateWorksForClient(string associateId, string clientId)
 {
     try
     {
         var client    = ClientRepository.GetClientById(clientId);
         var associate = AssociateRepository.LoadAssociateWithClients(associateId);
         if (client == null)
         {
             throw new MissingMemberException($"Client with id {clientId} not found!");
         }
         if (associate == null)
         {
             throw new MissingMemberException($"Associate with id {associateId} not found!");
         }
         AssociateService.AssociateWorkForClient(associate, client);
         return(Created($"associates/{associate.AssociateId}/clients", associate));
     }
     catch (MissingMemberException ex)
     {
         return(BadRequest(ex.Message));
     }
 }