public ServerResponse <NewsAddResponse> Add(NewsModel request) { ServerResponse <NewsAddResponse> response = new ServerResponse <NewsAddResponse>(); try { var num = dal.Add(request); response.Data = new NewsAddResponse { Id = request.Id, Num = num }; if (num == 1) { response.Code = ServerResponseType.成功; } else { response.Code = ServerResponseType.空数据; } } catch (Exception ex) { response.Code = ServerResponseType.调用异常; response.ErrorMsg = ex.ToString(); Log.LogHelper.WriteErrorLog(GetType(), ex); } return(response); }
/// <summary> /// 添加单条数据 /// </summary> /// <param name="obj"></param> /// <returns></returns> public int Add(News obj) { return(dal.Add(obj)); }