Example #1
0
        public async Task <ApiResult> Delete([FromBody] int[] ids)
        {
            var result = await _groupManager.DeleteAsync(ids);

            if (result)
            {
                return(Succeeded());
            }
            return(result.ToString("团队"));
        }
Example #2
0
        public async Task <IActionResult> Delete([FromQuery] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _groupManager.DeleteAsync(id);

            return(Ok());
        }
        public async Task <ActionResult <Group> > Remove(Guid id)
        {
            var group = await _groupManager.FindByIdAsync(id);

            if (group == null)
            {
                return(NotFound());
            }

            return(await _groupManager.DeleteAsync(group));
        }
Example #4
0
        public async Task <IActionResult> DeleteAsync([FromRoute] long id)
        {
            if (!_user.HasPermission(Permissions.DELETE_GROUP))
            {
                throw new Shared.Exceptions.InsuficientPermission()
                      {
                          ResourceId        = id.ToString(),
                          ResourceName      = id.ToString(),
                          ResourceType      = typeof(Data.Models.Group),
                          MissingPermission = Permissions.DELETE_GROUP
                      }
            }
            ;
            await _manager.DeleteAsync(id);

            return(Ok());
        }
        public async Task DeleteAsync_WasExecute()
        {
            //arrange
            Group group = new Group {
                Id = 1
            };

            _repoMock.Setup(r => r.DeleteAsync <Group>(group.Id));
            _dataAdapter.Setup(d => d.Map <Group>(null)).Returns(group);
            _groupManager = new GroupManager(_repoMock.Object, _dataAdapter.Object);

            //act
            await _groupManager.DeleteAsync(group.Id);

            //assert
            _repoMock.Verify(mock => mock.DeleteAsync <Group>(group.Id), Times.Once());
        }