コード例 #1
0
        public ClearCartDTO ClearCart([FromBody] CartClearRequest cartClearRequest)
        {
            var responseJson = new ClearCartDTO();
            var serverAnswer = _cartService.ClearCart(cartClearRequest);

            if (serverAnswer.HasClear)
            {
                responseJson.status = Status.Success;
            }
            else
            {
                responseJson.dbErrors         = serverAnswer.DBErrors;
                responseJson.validationErrors = serverAnswer.ValidationErrors;
                responseJson.status           = Status.Failed;
            }

            return(responseJson);
        }
コード例 #2
0
        public CartClearResponse ClearCart(CartClearRequest request)
        {
            var response         = new CartClearResponse();
            var validationErrors = _cartValidation.CartClearRequestValidation.Validate(request);
            var dbErrors         = new List <DatabaseErrors>();

            if (validationErrors.Count != 0)
            {
                response.ValidationErrors = validationErrors;
            }
            else
            {
                try
                {
                    response.HasClear = _cartRepository.Clear(request.CartId);
                }
                catch (SqlException)
                {
                    dbErrors.Add(DatabaseErrors.DB_CONNECTION_FAILED);
                }
                response.DBErrors = dbErrors;
            }
            return(response);
        }