/// <summary>
        /// 新增Retailer
        /// </summary>
        protected virtual async Task <RetailerListDto> Create(RetailerEditDto input)
        {
            var entity = input.MapTo <Retailer>();
            var id     = await _entityRepository.InsertAndGetIdAsync(entity);

            return(entity.MapTo <RetailerListDto>());
        }
        /// <summary>
        /// 编辑Retailer
        /// </summary>
        protected virtual async Task <RetailerListDto> Update(RetailerEditDto input)
        {
            var entity = await _entityRepository.GetAsync(input.Id.Value);

            input.MapTo(entity);
            var result = await _entityRepository.UpdateAsync(entity);

            return(result.MapTo <RetailerListDto>());
        }
Beispiel #3
0
        /// <summary>
        /// 编辑Retailer
        /// </summary>
        //[AbpAuthorize(RetailerAppPermissions.Retailer_EditRetailer)]
        protected virtual async Task UpdateRetailerAsync(RetailerEditDto input)
        {
            //TODO:更新前的逻辑判断,是否允许更新
            var entity = await _retailerRepository.GetAsync(input.Id.Value);

            input.MapTo(entity);

            // ObjectMapper.Map(input, entity);
            await _retailerRepository.UpdateAsync(entity);
        }
Beispiel #4
0
        /// <summary>
        /// 新增Retailer
        /// </summary>
        //[AbpAuthorize(RetailerAppPermissions.Retailer_CreateRetailer)]
        protected virtual async Task <RetailerEditDto> CreateRetailerAsync(RetailerEditDto input)
        {
            //TODO:新增前的逻辑判断,是否允许新增
            var entity = ObjectMapper.Map <Retailer>(input);

            entity.TenantId = AbpSession.TenantId;
            entity          = await _retailerRepository.InsertAsync(entity);

            return(entity.MapTo <RetailerEditDto>());
        }
Beispiel #5
0
 /// <summary>
 /// 添加或者修改Retailer的方法
 /// </summary>
 /// <param name="input">零售客户实体</param>
 /// <returns></returns>
 public async Task CreateOrUpdateRetailerDto(RetailerEditDto input)
 {
     if (input.Id.HasValue)
     {
         await UpdateRetailerAsync(input);
     }
     else
     {
         await CreateRetailerAsync(input);
     }
 }
 /// <summary>
 /// 添加或者修改Retailer的公共方法
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public async Task <RetailerListDto> CreateOrUpdateRetailerByIdAsync(RetailerEditDto input)
 {
     if (input.Id.HasValue)
     {
         return(await Update(input));
     }
     else
     {
         return(await Create(input));
     }
 }
Beispiel #7
0
        /// <summary>
        /// 导出Retailer为excel表
        /// </summary>
        /// <returns></returns>
        //public async Task<FileDto> GetRetailersToExcel(){
        //var users = await UserManager.Users.ToListAsync();
        //var userListDtos = ObjectMapper.Map<List<UserListDto>>(users);
        //await FillRoleNames(userListDtos);
        //return _userListExcelExporter.ExportToFile(userListDtos);
        //}
        /// <summary>
        /// MPA版本才会用到的方法
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <GetRetailerForEditOutput> GetRetailerForEdit(NullableIdDto <Guid> input)
        {
            var             output = new GetRetailerForEditOutput();
            RetailerEditDto retailerEditDto;

            if (input.Id.HasValue)
            {
                var entity = await _retailerRepository.GetAsync(input.Id.Value);

                retailerEditDto = entity.MapTo <RetailerEditDto>();

                //retailerEditDto = ObjectMapper.Map<List <retailerEditDto>>(entity);
            }
            else
            {
                retailerEditDto = new RetailerEditDto();
            }

            output.Retailer = retailerEditDto;
            return(output);
        }