public ActionResult updateCustomizedProductCollection(long id, [FromBody] UpdateCustomizedProductCollectionModelView updateCustomizedProductCollectionModelView) { if (updateCustomizedProductCollectionModelView == null) { return(BadRequest(new SimpleJSONMessageService(INVALID_REQUEST_BODY_MESSAGE))); } try { updateCustomizedProductCollectionModelView.customizedProductCollectionId = id; GetBasicCustomizedProductCollectionModelView updatedCollection = new core.application.CustomizedProductCollectionController().updateCollectionBasicInformation(updateCustomizedProductCollectionModelView); return(Ok(updatedCollection)); } catch (ResourceNotFoundException resourceNotFoundException) { return(NotFound(new SimpleJSONMessageService(resourceNotFoundException.Message))); } catch (InvalidOperationException invalidOperationException) { return(BadRequest(new SimpleJSONMessageService(invalidOperationException.Message))); } catch (ArgumentException invalidArgumentsException) { return(BadRequest(new SimpleJSONMessageService(invalidArgumentsException.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult addCustomizedProductCollection([FromBody] AddCustomizedProductCollectionModelView addCustomizedProductCollectionModelView) { if (addCustomizedProductCollectionModelView == null) { return(BadRequest(new SimpleJSONMessageService(INVALID_REQUEST_BODY_MESSAGE))); } try { GetCustomizedProductCollectionModelView createdCustomizedProductCollection = new core.application.CustomizedProductCollectionController().addCollection(addCustomizedProductCollectionModelView); return(Created(Request.Path, createdCustomizedProductCollection)); } catch (InvalidOperationException invalidOperationException) { return(BadRequest(new SimpleJSONMessageService(invalidOperationException.Message))); } catch (ArgumentException invalidArgumentsException) { return(BadRequest(new SimpleJSONMessageService(invalidArgumentsException.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult addCustomizedProductsToCustomizedProductCollection(long id, [FromBody] AddCustomizedProductToCustomizedProductCollectionModelView addCustomizedProductToCustomizedProductCollectionModelView) { if (addCustomizedProductToCustomizedProductCollectionModelView == null) { return(BadRequest(new SimpleJSONMessageService(INVALID_REQUEST_BODY_MESSAGE))); } try { addCustomizedProductToCustomizedProductCollectionModelView.customizedProductCollectionId = id; GetCustomizedProductCollectionModelView updatedCustomizedProductCollectionModelView = new core.application.CustomizedProductCollectionController().addCustomizedProductToCustomizedProductCollection(addCustomizedProductToCustomizedProductCollectionModelView); return(Created(Request.Path, updatedCustomizedProductCollectionModelView)); } catch (ResourceNotFoundException resourceNotFoundException) { return(NotFound(new SimpleJSONMessageService(resourceNotFoundException.Message))); } catch (InvalidOperationException invalidOperationException) { return(BadRequest(new SimpleJSONMessageService(invalidOperationException.Message))); } catch (ArgumentException argumentException) { return(BadRequest(new SimpleJSONMessageService(argumentException.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
/// <summary> /// Fetches all available customized product collections /// </summary> /// <returns>ActionResult with all available customized product collections or an error message</returns> private ActionResult findAll() { try { GetAllCustomizedProductCollectionsModelView modelView = new core.application.CustomizedProductCollectionController().findAllCollections(); return(Ok(modelView)); } catch (ResourceNotFoundException resourceNotFoundException) { return(NotFound(new SimpleJSONMessageService(resourceNotFoundException.Message))); } }
/// <summary> /// Fetches a customized product collection by its name /// </summary> /// <param name="name">name of the customized product collection</param> /// <returns>ActionResult with the requested customized product collection or an error message</returns> private ActionResult findByName(string name) { try { GetCustomizedProductCollectionModelView modelView = new GetCustomizedProductCollectionModelView(); modelView.name = name; GetCustomizedProductCollectionModelView customizedProductCollectionModelView = new core.application.CustomizedProductCollectionController().findCollectionByEID(modelView); return(Ok(customizedProductCollectionModelView)); } catch (ResourceNotFoundException resourceNotFoundException) { return(NotFound(new SimpleJSONMessageService(resourceNotFoundException.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }