Beispiel #1
0
        /// <summary>
        /// Execute convert output.
        /// </summary>
        /// <param name="resultObject">DataModel</param>
        /// <returns>ResponseModel</returns>
        private UpdateResponseModel Convert(UpdateDataModel resultObject)
        {
            // Local variable declaration
            UpdateResponseModel responseModel = null;

            // Variable initialize
            responseModel = new UpdateResponseModel();

            // Set value
            responseModel.Cart = resultObject.Cart;

            // Return value
            return responseModel;
        }
Beispiel #2
0
        /// <summary>
        /// Execute convert input.
        /// </summary>
        /// <param name="request">RequestModel</param>
        /// <returns>DataModel</returns>
        private UpdateDataModel Convert(UpdateRequestModel request)
        {
            // Local variable declaration
            UpdateDataModel inputObject = null;

            // Variable initialize
            inputObject = new UpdateDataModel();

            // Convert data input
            DataHelper.ConvertInput(request, inputObject);
            // Convert cart
            inputObject.Cart = DataHelper.ConvertInputCart(request.Cart);

            // Return value
            return inputObject;
        }
Beispiel #3
0
        /// <summary>
        /// Check processing
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>ResultModel</returns>
        private void Check(UpdateDataModel inputObject)
        {
            // Local variable declaration
            DataCom dataCom = null;
            CartCom cartCom = null;

            // Variable initialize
            dataCom = new DataCom();
            cartCom = new CartCom(inputObject.Cart);

            // Check valid
            foreach (var item in cartCom.Items)
            {
                if (!dataCom.IsExist<Item>(item.ItemCd, false))
                    throw new DataNotExistException(string.Format("Sản phẩm ({0})", item.ItemCd));
                if (DataCheckHelper.IsNull(item.Quantity))
                    throw new ExecuteException("E_MSG_00001", "Số lượng");
                if (item.Quantity <= decimal.Zero)
                    throw new ExecuteException("E_MSG_00011", "Số lượng");
            }
        }
Beispiel #4
0
        /// <summary>
        /// Update item to cart
        /// </summary>
        /// <param name="inputObject">DataModel</param>
        /// <returns>DataModel</returns>
        private UpdateDataModel UpdateInfo(UpdateDataModel inputObject)
        {
            // Local variable declaration
            UpdateDataModel getResult = null;
            CartCom cartCom = null;

            // Variable initialize
            getResult = new UpdateDataModel();
            cartCom = new CartCom(inputObject.Cart);

            // Get data
            foreach (var obj in inputObject.ListItems)
            {
                if (DataCheckHelper.IsNull(obj.Quantity)
                    || obj.Quantity < decimal.Zero) continue;
                var item = new CartItem();
                item.ItemCd = obj.ItemCd;
                item.Quantity = obj.Quantity.Value;
                cartCom.UpdateItem(item);
            }

            // Set value
            getResult.Cart = cartCom.Items;

            // Return value
            return getResult;
        }