public IActionResult DeleteCustomFileMaterialProp(int materialId, Guid propId) { try { // Get custom prop and validate type CustomMaterialProp prop = CustomMaterialPropService.GetCustomMaterialProp(propId); if (prop.Type != PropType.File) { return(HandleBadRequest("The submitted prop is not of the type `file`.")); } // Update material - remove prop MaterialsService.UpdateCustomFileMaterialProp(materialId, prop, null); // Done! return(NoContent()); } catch (CustomPropNotFoundException exception) { return(HandleResourceNotFoundException(exception)); } catch (MaterialNotFoundException exception) { return(HandleResourceNotFoundException(exception)); } catch (Exception exception) { return(HandleUnexpectedException(exception)); } }
public IActionResult SetCustomFileMaterialProp(int materialId, Guid propId, IFormFile file) { if (file.Length <= 0) { return(HandleBadRequest("No file content found.")); } try { // Get custom prop and validate type CustomMaterialProp prop = CustomMaterialPropService.GetCustomMaterialProp(propId); if (prop.Type != PropType.File) { return(HandleBadRequest("The submitted prop is not of the type `file`.")); } MaterialsService.UpdateCustomFileMaterialProp(materialId, prop, file); // Done! return(NoContent()); } catch (CustomPropNotFoundException exception) { return(HandleResourceNotFoundException(exception)); } catch (MaterialNotFoundException exception) { return(HandleResourceNotFoundException(exception)); } catch (Exception exception) { return(HandleUnexpectedException(exception)); } }