예제 #1
0
        public virtual async Task ModifyAsync(CompanyAInfoRequest companyAInfoRequest, CancellationToken cancellation = default(CancellationToken))
        {
            if (companyAInfoRequest == null)
            {
                throw new ArgumentNullException(nameof(companyAInfoRequest));
            }

            var companyAInfo = _mapper.Map <CompanyAInfo>(companyAInfoRequest);
            await Store.UpdateAsync(companyAInfo);
        }
예제 #2
0
        public virtual async Task <CompanyAInfoResponse> CreateAsync(UserInfo userInfo, CompanyAInfoRequest companyAInfoRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (companyAInfoRequest == null)
            {
                throw new ArgumentNullException(nameof(companyAInfoRequest));
            }

            var companyAInfo = _mapper.Map <CompanyAInfo>(companyAInfoRequest);

            if (string.IsNullOrEmpty(companyAInfo.ID))
            {
                companyAInfo.ID = Guid.NewGuid().ToString();
            }
            companyAInfo.CreateUser = userInfo.Id;
            companyAInfo.CreateTime = DateTime.Now;
            var info = await Store.CreateAsync(companyAInfo, cancellationToken);

            return(_mapper.Map <CompanyAInfoResponse>(info));
        }
예제 #3
0
        public async Task <ResponseMessage <bool> > ModifyCompanyAInfo(UserInfo User, [FromBody] CompanyAInfoRequest request, [FromRoute] string id)
        {
            Logger.Trace($"用户{User?.UserName ?? ""}({User?.Id ?? ""})修改甲方公司信息(ModifyCompanyAInfo):\r\n请求参数为:\r\n" + (request != null ? JsonHelper.ToJson(request) : ""));

            var response = new ResponseMessage <bool>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                return(response);
            }


            try
            {
//                 var companyAInfo = await _extraDataInfoManager.GetCompanyAInfoAsync(id, HttpContext.RequestAborted);
//                 if(companyAInfo == null)
//                 {
//                     response.Code = ResponseCodeDefines.ArgumentNullError;
//                     response.Message = "该甲方公司不存在";
//                     return response;
//                 }

                await _extraDataInfoManager.ModifyAsync(request, HttpContext.RequestAborted);

                response.Extension = true;
                response.Message   = "添加成功!";
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"用户{User?.UserName ?? ""}({User?.Id ?? ""})修改甲方公司信息报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + (request != null ? JsonHelper.ToJson(request) : ""));
            }

            return(response);
        }
예제 #4
0
        public async Task <ResponseMessage <CompanyAInfoResponse> > AddCompanyAInfo(UserInfo User, [FromBody] CompanyAInfoRequest request)
        {
            Logger.Trace($"用户{User?.UserName ?? ""}({User?.Id ?? ""})添加甲方公司信息(AddCompanyAInfo):\r\n请求参数为:\r\n" + (request != null ? JsonHelper.ToJson(request) : ""));

            var response = new ResponseMessage <CompanyAInfoResponse>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                return(response);
            }

            try
            {
                //写发送成功后的表

                response.Extension = await _extraDataInfoManager.CreateAsync(User, request, HttpContext.RequestAborted);

                response.Message = "添加成功!";
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"用户{User?.UserName ?? ""}({User?.Id ?? ""})添加甲方公司信息报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + (request != null ? JsonHelper.ToJson(request) : ""));
            }

            return(response);
        }