Exemplo n.º 1
0
        /// <summary>
        /// Updates a customized product collection's basic information
        /// </summary>
        /// <param name="modelView">model view with the updates for a customized product collection</param>
        /// <returns>Updated customized product collection or throws an exception if an error occurs</returns>
        public static CustomizedProductCollection update(UpdateCustomizedProductCollectionModelView modelView)
        {
            CustomizedProductCollectionRepository customizedProductCollectionRepository =
                PersistenceContext.repositories()
                .createCustomizedProductCollectionRepository();


            CustomizedProductCollection customizedProductCollection =
                customizedProductCollectionRepository.find(modelView.customizedProductCollectionId);

            checkIfCustomizedProductCollectionWasFound(
                customizedProductCollection, modelView.customizedProductCollectionId
                );

            customizedProductCollection.changeName(modelView.name);

            CustomizedProductCollection updatedCustomizedProductCollection =
                customizedProductCollectionRepository.update(customizedProductCollection);

            checkIfUpdatedCustomizedProductCollectionWasSaved(
                updatedCustomizedProductCollection, modelView.customizedProductCollectionId
                );

            return(updatedCustomizedProductCollection);
        }
Exemplo n.º 2
0
        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)));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates basic information of a customized product collection
        /// </summary>
        /// <param name="modelView">UpdateCustomizedProductCollectionDTO with the customized product collection update information</param>
        /// <returns>boolean true if the update was successful, false if not</returns>
        public GetBasicCustomizedProductCollectionModelView updateCollectionBasicInformation(UpdateCustomizedProductCollectionModelView modelView)
        {
            CustomizedProductCollection updatedCustomizedProductCollection = UpdateCustomizedProductCollectionService.update(modelView);

            return(CustomizedProductCollectionModelViewService.fromEntityAsBasic(updatedCustomizedProductCollection));
        }