/// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public Common.ClientResult.Result Post([FromBody] CRM_CompanyLadderPrice_Audit entity)
        {
            Common.ClientResult.Result      result = new Common.ClientResult.Result();
            IBLL.ICRM_CompanyLadderPriceBLL bll    = new CRM_CompanyLadderPriceBLL();
            if (entity != null && ModelState.IsValid)
            {
                int    currentPerson     = LoginInfo.UserID;
                string currentPersonName = LoginInfo.RealName;
                int    intBranchID       = LoginInfo.BranchID;
                entity.CreateTime     = DateTime.Now;
                entity.CreateUserID   = currentPerson;
                entity.CreateUserName = currentPersonName;
                entity.BranchID       = intBranchID;
                entity.OperateStatus  = 1; //待处理
                entity.OperateNode    = 2; //质控

                if (!bll.CheckRange(Convert.ToInt32(entity.CRM_Company_ID), entity.PRD_Product_ID, Convert.ToInt32(entity.BeginLadder), Convert.ToInt32(entity.EndLadder), intBranchID, null))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",客户_企业阶梯报价信息", "客户_企业阶梯报价信息_启用"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "请检查阶梯报价范围!";
                    return(result); //提示更新失败
                }

                string returnValue = string.Empty;
                if (m_BLL.Create(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",客户_企业阶梯报价_待审核的信息的Id为" + entity.ID, "客户_企业阶梯报价_待审核"
                                                   );//写入日志
                    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 + ",客户_企业阶梯报价_待审核的信息," + returnValue, "客户_企业阶梯报价_待审核"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.InsertFail + returnValue;
                    return(result); //提示插入失败
                }
            }

            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对
            return(result);
        }
        // PUT api/<controller>/5
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Common.ClientResult.Result Put([FromBody] CRM_CompanyLadderPrice entity)
        {
            Common.ClientResult.Result      result = new Common.ClientResult.Result();
            IBLL.ICRM_CompanyLadderPriceBLL bll    = new CRM_CompanyLadderPriceBLL();
            if (entity != null && ModelState.IsValid)
            {
                //数据校验
                if (!bll.CheckRange(entity.CRM_Company_ID, entity.PRD_Product_ID, Convert.ToInt32(entity.BeginLadder), Convert.ToInt32(entity.EndLadder), LoginInfo.BranchID, entity.ID))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",客户_企业阶梯报价信息的Id为" + entity.ID, "客户_企业阶梯报价"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = "请检查阶梯报价范围!";
                    return(result); //提示更新失败
                }

                CRM_CompanyLadderPrice_Audit model = GetModel(entity);

                string returnValue = string.Empty;
                if (m_BLL.ModifyLadderPrice(ref validationErrors, model))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",客户_企业阶梯报价信息的Id为" + entity.ID, "客户_企业阶梯报价_待审批"
                                                   );//写入日志
                    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 + ",客户_企业阶梯报价_待审批信息的Id为" + entity.ID + "," + returnValue, "客户_企业阶梯报价_待审批"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.UpdateFail + returnValue;
                    return(result); //提示更新失败
                }
            }
            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式";
            return(result); //提示输入的数据的格式不对
        }
Exemple #3
0
 public CRM_CompanyLadderPriceApiController(CRM_CompanyLadderPriceBLL bll)
 {
     m_BLL = bll;
 }