コード例 #1
0
        public async Task <Result> AddData(int attributeId, [FromBody] ProductAttributeDataParam model)
        {
            var data = new ProductAttributeData
            {
                AttributeId = attributeId,
                IsPublished = model.IsPublished,
                Value       = model.Value,
                Description = model.Description
            };

            _productAttrDataRepository.Add(data);
            await _productAttrDataRepository.SaveChangesAsync();

            return(Result.Ok());
        }
コード例 #2
0
        public async Task <Result> EditData(int id, [FromBody] ProductAttributeDataParam model)
        {
            var data = await _productAttrDataRepository.FirstOrDefaultAsync(id);

            if (data == null)
            {
                return(Result.Fail("单据不存在"));
            }
            data.IsPublished = model.IsPublished;
            data.Value       = model.Value;
            data.Description = model.Description;
            data.UpdatedOn   = DateTime.Now;
            await _productAttrDataRepository.SaveChangesAsync();

            return(Result.Ok());
        }