Beispiel #1
0
        public async Task CreateOrEditAsync(CreateOrEditDto model)
        {
            long goodsId = 0;

            if (model.Goods.Id > 0)
            {
                goodsId = model.Goods.Id;
                await _Repository.UpdateAsync(model.Goods);

                if (model.ValueList.Count > 0)
                {
                    await _specObjService.Delete(model.Goods.Id, 0);
                }
            }
            else
            {
                goodsId = await _Repository.InsertAndGetIdAsync(model.Goods);

                for (int i = 0; i < model.ImageList.Count; i++)
                {
                    model.ImageList[i].ObjectId = goodsId;
                }
            }

            for (int i = 0; i < model.ValueList.Count; i++)
            {
                model.ValueList[i].ObjectId = goodsId;
                model.ValueList[i].TenantId = model.Goods.TenantId;
                model.ValueList[i].Type     = 0;
                await _specObjService.AddOrEdit(model.ValueList[i]);
            }
            await _imgService.CreateOrEditAsync(model.ImageList);
        }