Esempio n. 1
0
 /// <summary>
 /// 创建一个变送器cos
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个变送器cos</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, TRANSMITTER_COS entity)
 {
     try
     {
         repository.Create(entity);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Esempio n. 2
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public Common.ClientResult.Result Post([FromBody] TRANSMITTER_COS entity)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();
            if (entity != null && ModelState.IsValid)
            {
                string currentPerson = GetCurrentPerson();
                entity.CREATETIME   = DateTime.Now;
                entity.CREATEPERSON = currentPerson;

                entity.ID = Result.GetNewId();
                string returnValue = string.Empty;
                if (m_BLL.Create(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",变送器cos的信息的Id为" + entity.ID, "变送器cos"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Succeed;
                    result.Message = Suggestion.InsertSucceed;
                    return(result); //提示创建成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",变送器cos的信息," + returnValue, "变送器cos"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.InsertFail + returnValue;
                    return(result); //提示插入失败
                }
            }

            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对
            return(result);
        }
Esempio n. 3
0
        // PUT api/<controller>/5
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Common.ClientResult.Result Put([FromBody] TRANSMITTER_COS entity)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();
            if (entity != null && ModelState.IsValid)
            {   //数据校验
                string currentPerson = GetCurrentPerson();
                entity.UPDATETIME   = DateTime.Now;
                entity.UPDATEPERSON = currentPerson;

                string returnValue = string.Empty;
                if (m_BLL.Edit(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",变送器cos信息的Id为" + entity.ID, "变送器cos"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Succeed;
                    result.Message = Suggestion.UpdateSucceed;
                    return(result); //提示更新成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",变送器cos信息的Id为" + entity.ID + "," + returnValue, "变送器cos"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.UpdateFail + returnValue;
                    return(result); //提示更新失败
                }
            }
            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式";
            return(result); //提示输入的数据的格式不对
        }
Esempio n. 4
0
        /// <summary>
        /// 根据ID获取数据模型
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns></returns>
        public TRANSMITTER_COS Get(string id)
        {
            TRANSMITTER_COS item = m_BLL.GetById(id);

            return(item);
        }