Beispiel #1
0
        /// <summary>
        /// 修改客户
        /// </summary>
        /// <param name="input">条件参数</param>
        /// <returns></returns>
        public async Task <ActionResult> UpdatePptCustomer(Ppt_Customer_AppUpdateInputDto input)
        {
            try
            {
                var result = await _appService.Update(input);

                return(Ok(JsonUtils.SerializeObject(true, "success")));
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("异常消息:{0} {1}", ex.Message, ex.InnerException?.Message);
                return(BadRequest(JsonUtils.SerializeObject(false, "failed", ex.Message)));
            }
        }
        /// <summary>
        /// 修改验证
        /// </summary>
        /// <param name="input">条件参数</param>
        /// <returns></returns>
        public async Task <string> UpdateValidateAsync(Ppt_Customer_AppUpdateInputDto input)
        {
            try
            {
                string errMsg     = string.Empty;
                var    errMsgList = new List <string>();
                errMsg = await UpdateValidateAsync(input, errMsgList);

                return(errMsg);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 数据验证
        /// </summary>
        /// <param name="input">条件参数</param>
        /// <param name="errMsgList">错误信息集合</param>
        /// <returns></returns>
        private async Task <string> UpdateValidateAsync(Ppt_Customer_AppUpdateInputDto input, List <string> errMsgList)
        {
            try
            {
                var count = await _repository.CountAsync(d => d.TenantId == input.TenantId && d.Name == input.Name && d.Customertype == input.Customertype && d.Id != input.Id);

                if (count > 0)
                {
                    errMsgList.Add(string.Format($"[客户 {input.Name} 已存在]"));
                }
                return(string.Join(',', errMsgList));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }