Exemplo n.º 1
0
        public async Task <ActionResult <SheriffDto> > UpdateSheriff(SheriffWithIdirDto updateSheriff)
        {
            await CheckForAccessToSheriffByLocation(updateSheriff.Id);

            var canEditIdir = User.HasPermission(Permission.EditIdir);
            var sheriff     = updateSheriff.Adapt <Sheriff>();

            sheriff = await SheriffService.UpdateSheriff(sheriff, canEditIdir);

            return(Ok(sheriff.Adapt <SheriffDto>()));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <SheriffDto> > AddSheriff(SheriffWithIdirDto addSheriff)
        {
            if (!PermissionDataFiltersExtensions.HasAccessToLocation(User, Db, addSheriff.HomeLocationId))
            {
                return(Forbid());
            }

            var sheriff = addSheriff.Adapt <Sheriff>();

            sheriff = await SheriffService.AddSheriff(sheriff);

            return(Ok(sheriff.Adapt <SheriffDto>()));
        }