zoukankan      html  css  js  c++  java
  • web api post

    这是显示端

    function load() {
    $.ajax({
    type: "post",
    url: "http://localhost:63211/api/MeetingRoomService/AddMeetiongType",
    dataType: "json",
    data: { "Typename": "123" },
    success: function (data) {
    renderContactList(data);
    alert(data.data);
    },error: function (XMLHttpRequest, textStatus, errorThrown) {

    alert(data.data);
    }
    });
    }

    这是服务端

    [HttpPost]
    public ResultEntity<bool> AddMeetiongType([FromBody]MeetingType mt)
    {
    ExceptionManager.Handle(new Exception("TypeName>>>>>>" + mt.Typename));
    ResultEntity<bool> result = new ResultEntity<bool>();
    result.errors = new List<ErrorEntity>();
    ErrorEntity error = new ErrorEntity();
    result.action_code = ActionCode.SUCCESS.ToString();
    try
    {
    Check.CheckParameter(mt.Typename);
    if (bll.GetMeetingRoomTypeExist(mt.Typename) == false)
    {
    if (bll.AddMeetingRoomType(mt.Typename))
    {
    error.message = "插入成功";
    result.data = true;

    }
    else
    {
    result.action_code = ActionCode.FAILED.ToString();
    error.message = "插入失败";
    result.data = false;

    }
    }
    else
    {
    result.action_code = ActionCode.FAILED.ToString();
    error.message = "此信息已经存在";

    }


    }
    catch (ArgumentException e)
    {
    ExceptionManager.Handle(e);
    result.action_code = ActionCode.FAILED.ToString();
    error.message = e.Message;
    }
    catch (Exception ex)
    {
    ExceptionManager.Handle(ex);
    result.action_code = ActionCode.FAILED.ToString();
    error.message = "添加类型接口出错了!";
    }
    result.errors.Add(error);
    return result;
    }

    第一个 web api post的程序

    今天居然忘记了判断一个dataset是否为空的方法

    ds.Tables[0].Rows.Count >0

  • 相关阅读:
    ThinkPHP3.2 整合支付宝RSA加密方式
    代码风格规范
    Mac下安装composer
    MAC 下安装RabbitMQ
    Redis配置
    git 分支
    PHP常用数组操作方法汇总
    php 不用第三个变量 交换两个变量的值汇总
    PHP配置错误信息回报的等级
    Apache同一个IP上配置多域名
  • 原文地址:https://www.cnblogs.com/Demcia/p/3865870.html
Copyright © 2011-2022 走看看