public ActionResult addRestrictionToProductMaterial(long productId, long materialId, [FromBody] AddRestrictionModelView restrictionMV) { if (restrictionMV == null) { return(BadRequest(new SimpleJSONMessageService(INVALID_RESTRICTION_DATA))); } AddProductMaterialRestrictionModelView addRestrictionToProductMaterialMV = new AddProductMaterialRestrictionModelView(); addRestrictionToProductMaterialMV.productId = productId; addRestrictionToProductMaterialMV.materialId = materialId; addRestrictionToProductMaterialMV.restriction = restrictionMV; try { GetProductModelView productModelView = new core.application.ProductController().addRestrictionToProductMaterial(addRestrictionToProductMaterialMV); return(Created(Request.Path, productModelView)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (ArgumentException e) { return(BadRequest(new SimpleJSONMessageService(e.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult addRestrictionToProductComponent(long productID, long componentID, [FromBody] AddRestrictionModelView restrictionMV) { if (restrictionMV == null) { return(BadRequest(new SimpleJSONMessageService(INVALID_RESTRICTION_DATA))); } AddComponentRestrictionModelView addRestrictionToProductComponentDTO = new AddComponentRestrictionModelView(); addRestrictionToProductComponentDTO.fatherProductId = productID; addRestrictionToProductComponentDTO.childProductId = componentID; addRestrictionToProductComponentDTO.restriction = restrictionMV; try { GetProductModelView appliedRestrictionModelView = new core.application.ProductController().addRestrictionToProductComponent(addRestrictionToProductComponentDTO); return(Created(Request.Path, appliedRestrictionModelView)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (ArgumentException e) { return(BadRequest(new SimpleJSONMessageService(e.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }