コード例 #1
0
        public void TestRemoveParticipantFromMyGroup()
        {
            _groupService.Setup(mocked => mocked.RemoveParticipantFromGroup(_auth, 2, 3));
            var groupInfo = new GroupParticipantRemovalDto();

            groupInfo.GroupId            = 2;
            groupInfo.GroupParticipantId = 3;
            var result = _fixture.RemoveSelfFromGroup(groupInfo);

            _groupService.VerifyAll();

            Assert.IsNotNull(result);
            Assert.IsInstanceOf <OkResult>(result);
        }
コード例 #2
0
 public IHttpActionResult RemoveSelfFromGroup([FromBody] GroupParticipantRemovalDto groupInformation)
 {
     return(Authorized(token =>
     {
         try
         {
             _groupService.RemoveParticipantFromGroup(token, groupInformation.GroupId, groupInformation.GroupParticipantId);
             return Ok();
         }
         catch (GroupParticipantRemovalException e)
         {
             var apiError = new ApiErrorDto(e.Message, null, e.StatusCode);
             throw new HttpResponseException(apiError.HttpResponseMessage);
         }
         catch (Exception ex)
         {
             var apiError = new ApiErrorDto(string.Format("Error removing group participant {0} from group {1}", groupInformation.GroupParticipantId, groupInformation.GroupId), ex);
             throw new HttpResponseException(apiError.HttpResponseMessage);
         }
     }));
 }