コード例 #1
0
        public async Task <ActionResult <LookupCodeDto> > Find(int id)
        {
            var entity = await ManageTypesService.Find(id);

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

            return(Ok(entity.Adapt <LookupCodeDto>()));
        }
コード例 #2
0
        public async Task <ActionResult <LookupCodeDto> > Add(AddLookupCodeDto lookupCodeDto)
        {
            if (lookupCodeDto == null)
            {
                return(BadRequest(InvalidLookupCodeError));
            }
            if (!PermissionDataFiltersExtensions.HasAccessToLocation(User, Db, lookupCodeDto.LocationId))
            {
                return(Forbid());
            }

            var lookupCode = await ManageTypesService.Add(lookupCodeDto);

            return(Ok(lookupCode.Adapt <LookupCodeDto>()));
        }
コード例 #3
0
        public async Task <ActionResult> UpdateSortOrders(SortOrdersDto sortOrdersDto)
        {
            if (sortOrdersDto == null)
            {
                return(BadRequest(InvalidLookupCodeError));
            }
            if (!PermissionDataFiltersExtensions.HasAccessToLocation(User, Db, sortOrdersDto.SortOrderLocationId))
            {
                return(Forbid());
            }

            await ManageTypesService.UpdateSortOrders(sortOrdersDto);

            return(NoContent());
        }
コード例 #4
0
        public async Task <ActionResult <LookupCodeDto> > UnExpire(int id)
        {
            var entity = await ManageTypesService.Find(id);

            if (entity == null)
            {
                return(NotFound());
            }
            if (!PermissionDataFiltersExtensions.HasAccessToLocation(User, Db, entity.LocationId))
            {
                return(Forbid());
            }

            var lookupCode = await ManageTypesService.Unexpire(id);

            return(Ok(lookupCode.Adapt <LookupCodeDto>()));
        }
コード例 #5
0
        public async Task <ActionResult <LookupCodeDto> > Update(LookupCodeDto lookupCodeDto)
        {
            if (lookupCodeDto == null)
            {
                return(BadRequest(InvalidLookupCodeError));
            }
            var entity = await ManageTypesService.Find(lookupCodeDto.Id);

            if (entity == null)
            {
                return(NotFound());
            }
            if (!PermissionDataFiltersExtensions.HasAccessToLocation(User, Db, lookupCodeDto.LocationId))
            {
                return(Forbid());
            }

            var lookupCode       = lookupCodeDto.Adapt <LookupCode>();
            var lookupCodeResult = await ManageTypesService.Update(lookupCode);

            return(Ok(lookupCodeResult.Adapt <LookupCodeDto>()));
        }
コード例 #6
0
 public ManageTypesController(ManageTypesService service)
 {
     _service = service;
 }
コード例 #7
0
        public async Task <ActionResult <List <LookupCodeDto> > > GetAll(LookupTypes?codeType, int?locationId, bool showExpired = false)
        {
            var lookupCodesDtos = (await ManageTypesService.GetAll(codeType, locationId, showExpired)).Adapt <List <LookupCodeDto> >();

            return(Ok(lookupCodesDtos));
        }
コード例 #8
0
 public ManageTypesController(ManageTypesService manageTypesService, SheriffDbContext db)
 {
     ManageTypesService = manageTypesService;
     Db = db;
 }