public HttpResponseMessage updateOrderStatus(ChangeOrdersStatusRequestModel changeOrdersStatusRequestModel)
        {
            ErrorModel       errorModel       = null;
            OrderProvider    provider         = new OrderProvider();
            var              status           = provider.updateOrderStatus(changeOrdersStatusRequestModel, out errorModel);
            APIResponseModel aPIResponseModel = new APIResponseModel();

            aPIResponseModel.Response = status;
            aPIResponseModel.Error    = errorModel;
            return(Request.CreateResponse(HttpStatusCode.OK, aPIResponseModel));
        }
 public ChangeOrderStatusResponseModel updateOrderStatus(ChangeOrdersStatusRequestModel changeOrdersStatusRequestModel, out ErrorModel errorModel)
 {
     errorModel = null;
     try
     {
         Order orderHelper = new Order();
         return(orderHelper.changeOrderStatus(changeOrdersStatusRequestModel, out errorModel));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Пример #3
0
        public ChangeOrderStatusResponseModel changeOrderStatus(ChangeOrdersStatusRequestModel changeOrdersStatusRequestModel, out ErrorModel errorModel)
        {
            errorModel = null;
            ChangeOrderStatusResponseModel changeOrderStatusResponse = new ChangeOrderStatusResponseModel();
            SqlConnection connection = null;

            try
            {
                using (connection = new SqlConnection(Database.getConnectionString()))
                {
                    SqlCommand command = new SqlCommand(SqlCommands.SP_updateOrderStatus, connection);
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("orderId", changeOrdersStatusRequestModel.orderId);
                    command.Parameters.AddWithValue("orderStatus", changeOrdersStatusRequestModel.orderStatus);
                    connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    if (reader.Read())
                    {
                        changeOrderStatusResponse.StatusCode    = reader["StatusCode"].ToString();
                        changeOrderStatusResponse.StatusMessage = reader["StatusMessage"].ToString();
                    }
                    command.Dispose();
                    return(changeOrderStatusResponse);
                }
            }
            catch (Exception e)
            {
                errorModel = new ErrorModel();
                errorModel.ErrorMessage = e.Message;
                return(null);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
        }