有關 C# WebAPI知識

一、【懶得安分博客總結的很全面html

二、關於基礎類型做入參數的問題ide

     參照此博客【ASP.NET WebAPI String 傳值問題測試

三、代碼說明spa

   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using PosWebAPi.Models;
using Newtonsoft.Json;


namespace PosWebAPi.Controllers
{/// <summary>
/// 
/// </summary>
    public class PosController : ApiController
    {
        /// <summary>
        /// 測試
        /// </summary>
        /// <returns></returns>
        [HttpGet]
     
        public string Test()
        {
            return "Hello   Word";
        }
        /// <summary>
        /// 總接口
        /// </summary>
        /// <param name="sInput"></param>
        /// <returns></returns>
        [HttpPost]
        public Result<object> ProcCYZZSY(string sInput)
        {

            return WorkServices.PosService._ProcCYZZSY(sInput);
        }
        [HttpPost]
       
        public Result<object> Amt(string sInput)
          {

        // var  s= JsonConvert.SerializeObject(sInput);
           //var str = Convert.ToString(sInput);

         //   Posinput pos = new Posinput();

            //  JsonConvert.DeserializeObject(sInput);

            return new Result<object>(true,"OK", sInput);
           // return WorkServices.PosService._Amt(sInput);
        }
        [HttpPost]
        public Result<object> Amt22(Msg msg)
        {

            return new Result<object>(true, "", msg.msg1);
        }

        public class Msg
        {
            public string msg1 { get; set; }
        }
    }
}
View Code

 

 

 

 

相關文章
相關標籤/搜索