public IActionResult CreateCustomMaterialProp([FromBody] CustomMaterialPropCreationRequest customMaterialPropCreationRequest) { if (customMaterialPropCreationRequest == null || string.IsNullOrWhiteSpace(customMaterialPropCreationRequest.Name)) { return(HandleBadRequest("Missing prop data: a name and type are required.")); } // Attempt to parse type PropType type; if (Enum.IsDefined(typeof(PropType), customMaterialPropCreationRequest.Type)) { type = (PropType)customMaterialPropCreationRequest.Type; } else { return(HandleBadRequest("A valid prop type needs to be provided.")); } // Attempt to create try { CustomMaterialProp prop = CustomMaterialPropService.CreateCustomMaterialProp(customMaterialPropCreationRequest.Name, type); return(Created(GetNewResourceUri(prop.Id), prop)); } catch (Exception exception) { return(HandleUnexpectedException(exception)); } }