예제 #1
0
        /// <summary>
        /// 新增客源不感兴趣的商铺列表信息
        /// </summary>
        /// <param name="customerNotShops">实体</param>
        /// <param name="cancellationToken">验证</param>
        /// <returns></returns>
        public async Task <CustomerNotShops> CreateCustomerNotShopAsync(CustomerNotShops customerNotShops, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (customerNotShops == null)
            {
                throw new ArgumentNullException(nameof(customerNotShops));
            }
            Context.Add(customerNotShops);
            await Context.SaveChangesAsync(cancellationToken);

            return(customerNotShops);
        }
예제 #2
0
        /// <summary>
        /// 新增用户不感兴趣商铺
        /// </summary>
        /// <param name="user"></param>
        /// <param name="customerNotShops"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public virtual async Task <ResponseMessage <CustomerNotShops> > CreateCustomerNotShopAsync(UserInfo user, CustomerNotShops customerNotShops, CancellationToken cancellationToken = default(CancellationToken))
        {
            var response = new ResponseMessage <CustomerNotShops>();

            if (customerNotShops == null)
            {
                throw new ArgumentNullException(nameof(customerNotShops));
            }
            response.Extension = await _shopsStore.CreateCustomerNotShopAsync(customerNotShops, cancellationToken);


            return(response);
        }
        public async Task <ResponseMessage <CustomerNotShops> > PostCustomerNotShops(UserInfo user, [FromBody] CustomerNotShops customerNotShops)
        {
            Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增客源不感兴趣商铺信息(PostCustomerNotShops):\r\n请求参数为:\r\n" + (customerNotShops != null ? JsonHelper.ToJson(customerNotShops) : ""));

            var response = new ResponseMessage <CustomerNotShops>();

            if (!ModelState.IsValid)
            {
                var error  = "";
                var errors = ModelState.Values.ToList();
                foreach (var item in errors)
                {
                    foreach (var e in item.Errors)
                    {
                        error += e.ErrorMessage + "  ";
                    }
                }
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = error;
                Logger.Warn($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增客源不感兴趣商铺信息(PostCustomerNotShops)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (customerNotShops != null ? JsonHelper.ToJson(customerNotShops) : ""));
                return(response);
            }
            try
            {
                response = await _shopsManager.CreateCustomerNotShopAsync(user, customerNotShops, HttpContext.RequestAborted);
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = "服务器错误" + e.ToString();
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增客源不感兴趣商铺信息(PostCustomerNotShops)请求失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (customerNotShops != null ? JsonHelper.ToJson(customerNotShops) : ""));
            }
            return(response);
        }