示例#1
0
        public IHttpActionResult Add(TOURIS_TV_DISTRICT districtView)
        {
            ApiResData res = new ApiResData();

            try
            {
                if (!ModelState.IsValid)
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                    resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.DataIsntValid)));
                    return(Content(HttpStatusCode.NotFound, resObj));
                }

                TOURIS_TM_DISTRICT district = new TOURIS_TM_DISTRICT();
                district.CITY_ID              = districtView.CITY_ID;
                district.DISTRICT_CODE        = districtView.DISTRICT_CODE;
                district.DISTRICT_NAME        = districtView.DISTRICT_NAME;
                district.DISTRICT_DESCRIPTION = districtView.DISTRICT_DESCRIPTION;
                district.CREATED_BY           = districtView.CREATED_BY;
                district.CREATED_TIME         = districtView.CREATED_TIME;
                district.ROW_STATUS           = eStat.fg.IsActive;

                rs = repo.Add(district);
                if (rs.IsSuccess)
                {
                    rs.SetSuccessStatus();
                }
                else
                {
                    rs.SetErrorStatus(eFunc.fg.SFailed);
                }

                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, null));

                return(Content(HttpStatusCode.OK, resObj));
            }
            catch (Exception ex)
            {
                rs.SetErrorStatus(ex.Message);
                resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Save, new Exception(eFunc.fg.SFailed)));
                return(Content(HttpStatusCode.BadRequest, resObj));
            }
        }
示例#2
0
 /// <summary>
 /// 添加一条数据
 /// </summary>
 /// <param name="model">数据实体</param>
 /// <returns></returns>
 public int Add(Models.APP.District model)
 {
     return(dal.Add(model));
 }