Beispiel #1
0
        public async Task <Result> AddData(int optionId, [FromBody] ProductOptionDataParam model)
        {
            var data = new ProductOptionData
            {
                OptionId    = optionId,
                IsPublished = model.IsPublished,
                Value       = model.Value,
                Description = model.Description,
                Display     = model.Display
            };

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

            return(Result.Ok());
        }
Beispiel #2
0
        public async Task <Result> EditData(int id, [FromBody] ProductOptionDataParam model)
        {
            var data = await _productOptionDataRepository.FirstOrDefaultAsync(id);

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

            return(Result.Ok());
        }