public async Task <ActionResult <LookupCodeDto> > Find(int id) { var entity = await ManageTypesService.Find(id); if (entity == null) { return(NotFound()); } return(Ok(entity.Adapt <LookupCodeDto>())); }
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>())); }
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()); }
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>())); }
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>())); }
public ManageTypesController(ManageTypesService service) { _service = service; }
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)); }
public ManageTypesController(ManageTypesService manageTypesService, SheriffDbContext db) { ManageTypesService = manageTypesService; Db = db; }