Exemplo n.º 1
0
        public async Task <APIResult> SaveDealerList(ParamDealerDto paramDto)
        {
            if (paramDto.DisList != null)
            {
                paramDto.DisList = paramDto.DisList.Where(a => a.DisCode != null).ToList <DealerDto>();
            }
            string            spName     = @"up_RMMT_BAS_SaveDealers_C";
            string            xmlDisList = CommonHelper.Serializer(typeof(List <DealerDto>), paramDto.DisList);
            DynamicParameters dp         = new DynamicParameters();

            dp.Add("@InUserId", paramDto.InUserId, DbType.Int32);
            dp.Add("@XmlData", xmlDisList, DbType.Xml);
            dp.Add("@XmlRootName", "/ArrayOfDealerDto/DealerDto", DbType.String);
            using (var conn = new SqlConnection(DapperContext.Current.SqlConnection))
            {
                conn.Open();
                IEnumerable <DisInfoDto> list;
                using (var tran = conn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted))
                {
                    try
                    {
                        list = await conn.QueryAsync <DisInfoDto>(spName, dp, tran, null, CommandType.StoredProcedure);

                        tran.Commit();
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        return(new APIResult {
                            Body = "", ResultCode = ResultType.Failure, Msg = ex.Message
                        });
                    }
                    finally
                    {
                        tran.Dispose();
                    }
                }
                return(new APIResult {
                    Body = CommonHelper.EncodeDto <DisInfoDto>(list), ResultCode = ResultType.Success, Msg = ""
                });
            }
        }
Exemplo n.º 2
0
 public Task <APIResult> SaveDealerList([FromBody] ParamDealerDto paramDto)
 {
     return(_usersService.SaveDealerList(paramDto));
 }