public ActionResult findUserCreatedCustomizedProducts([FromHeader(Name = "UserToken")] string userAuthToken) { if (userAuthToken == null) { return(BadRequest(new SimpleJSONMessageService(MISSING_USER_TOKEN))); } try { FindUserCreatedCustomizedProductsModelView userCreatedCustomizedProductsModelView = new FindUserCreatedCustomizedProductsModelView(); userCreatedCustomizedProductsModelView.userAuthToken = userAuthToken; GetAllCustomizedProductsModelView allCustomizedProductsCreatedByUser = new core.application.CustomizedProductController() .findUserCreatedCustomizedProducts(userCreatedCustomizedProductsModelView); return(Ok(allCustomizedProductsCreatedByUser)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult updateSlot(long customizedProductId, long slotId, [FromBody] UpdateSlotModelView updateSlotModelView, [FromHeader(Name = "UserToken")] string userAuthToken) { if (updateSlotModelView == null) { return(BadRequest(new SimpleJSONMessageService(INVALID_REQUEST_BODY_MESSAGE))); } try { updateSlotModelView.customizedProductId = customizedProductId; updateSlotModelView.slotId = slotId; GetCustomizedProductModelView customizedProductModelView = new core.application.CustomizedProductController().updateSlot(updateSlotModelView); return(Ok(customizedProductModelView)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (NotAuthorizedException notAuthorizedException) { return(StatusCode(401, new SimpleJSONMessageService(notAuthorizedException.Message))); } catch (ArgumentException e) { return(BadRequest(new SimpleJSONMessageService(e.Message))); } catch (InvalidOperationException e) { return(BadRequest(new SimpleJSONMessageService(e.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult addSlotToCustomizedProduct(long id, [FromBody] AddCustomizedDimensionsModelView slotDimensions, [FromHeader(Name = "UserToken")] string userAuthToken) { if (slotDimensions == null) { return(BadRequest(new SimpleJSONMessageService(INVALID_REQUEST_BODY_MESSAGE))); } try { AddSlotModelView addSlotModelView = new AddSlotModelView(); addSlotModelView.customizedProductId = id; addSlotModelView.slotDimensions = slotDimensions; addSlotModelView.userAuthToken = userAuthToken; GetCustomizedProductModelView customizedProductModelView = new core.application.CustomizedProductController().addSlotToCustomizedProduct(addSlotModelView); return(Created(Request.Path, customizedProductModelView)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (NotAuthorizedException notAuthorizedException) { return(StatusCode(401, new SimpleJSONMessageService(notAuthorizedException.Message))); } catch (ArgumentException e) { return(BadRequest(new SimpleJSONMessageService(e.Message))); } catch (InvalidOperationException e) { return(BadRequest(new SimpleJSONMessageService(e.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult createMinimumSlots(long customizedProductId, [FromQuery] string unit, [FromHeader(Name = "UserToken")] string userAuthToken) { try { AddSlotLayoutModelView addSlotLayoutModelView = new AddSlotLayoutModelView(); addSlotLayoutModelView.customizedProductId = customizedProductId; addSlotLayoutModelView.userAuthToken = userAuthToken; addSlotLayoutModelView.options.unit = unit; GetCustomizedProductModelView customizedProductModelView = new core.application.CustomizedProductController().addMinimumSlots(addSlotLayoutModelView); return(Ok(customizedProductModelView)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (NotAuthorizedException notAuthorizedException) { return(StatusCode(401, new SimpleJSONMessageService(notAuthorizedException.Message))); } catch (InvalidOperationException e) { return(BadRequest(new SimpleJSONMessageService(e.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult addCustomizedProduct(long?customizedProductId, long?slotId, [FromHeader(Name = "UserToken")] string userAuthToken, [FromBody] AddCustomizedProductModelView customizedProductModelView) { if (customizedProductModelView == null) { return(BadRequest(new SimpleJSONMessageService(INVALID_REQUEST_BODY_MESSAGE))); } try { customizedProductModelView.parentCustomizedProductId = customizedProductId; customizedProductModelView.insertedInSlotId = slotId; customizedProductModelView.userAuthToken = userAuthToken; GetCustomizedProductModelView createdCustomizedProductModelView = new core.application .CustomizedProductController().addCustomizedProduct(customizedProductModelView); return(CreatedAtRoute("GetCustomizedProduct", new { id = createdCustomizedProductModelView.customizedProductId }, createdCustomizedProductModelView)); } catch (NotAuthorizedException notAuthorizedException) { return(StatusCode(401, new SimpleJSONMessageService(notAuthorizedException.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))); } }
public ActionResult findBaseCustomizedProducts() { try { GetAllCustomizedProductsModelView getAllModelView = new core.application.CustomizedProductController().findAllBaseCustomizedProducts(); return(Ok(getAllModelView)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult getRecommendedSlots(long customizedProductId, [FromQuery] string unit) { try { FindCustomizedProductModelView findCustomizedProductModelView = new FindCustomizedProductModelView(); findCustomizedProductModelView.customizedProductId = customizedProductId; findCustomizedProductModelView.options.unit = unit; GetAllCustomizedDimensionsModelView allCustomDimensionsMV = new core.application.CustomizedProductController().getRecommendedSlots(findCustomizedProductModelView); return(Ok(allCustomDimensionsMV)); } catch (ResourceNotFoundException ex) { return(NotFound(new SimpleJSONMessageService(ex.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult fetchPossibleComponents(long customizedProductId, long slotId) { try { FindPossibleComponentsModelView findPossibleComponents = new FindPossibleComponentsModelView(); findPossibleComponents.customizedProductID = customizedProductId; findPossibleComponents.slotID = slotId; GetPossibleComponentsModelView possibleComponents = new core.application.CustomizedProductController().fetchPossibleComponents(findPossibleComponents); return(Ok(possibleComponents)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (InvalidOperationException ex) { return(BadRequest(new SimpleJSONMessageService(ex.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult findSlotById(long customizedProductId, long slotId, [FromQuery] string unit) { try { FindSlotModelView findSlotModelView = new FindSlotModelView(); findSlotModelView.customizedProductId = customizedProductId; findSlotModelView.slotId = slotId; findSlotModelView.options.unit = unit; GetSlotModelView slotModelView = new core.application.CustomizedProductController().findSlot(findSlotModelView); return(Ok(slotModelView)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (Exception) { return(StatusCode(500, new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }
public ActionResult findByID(long id, [FromQuery] string unit) { try { FindCustomizedProductModelView findCustomizedProductModelView = new FindCustomizedProductModelView(); findCustomizedProductModelView.customizedProductId = id; findCustomizedProductModelView.options.unit = unit; GetCustomizedProductModelView fetchedCustomizedProduct = new core.application.CustomizedProductController().findCustomizedProduct(findCustomizedProductModelView); return(Ok(fetchedCustomizedProduct)); } catch (ResourceNotFoundException e) { return(NotFound(new SimpleJSONMessageService(e.Message))); } catch (InvalidOperationException e) { return(BadRequest(new SimpleJSONMessageService(e.Message))); } catch (Exception) { return(NotFound(new SimpleJSONMessageService(UNEXPECTED_ERROR))); } }