Beispiel #1
0
        public async Task <Result> Post([FromBody] ProductAttributeParam model)
        {
            var productAttribute = new ProductAttribute
            {
                Name    = model.Name,
                GroupId = model.GroupId
            };

            _productAttrRepository.Add(productAttribute);
            await _productAttrRepository.SaveChangesAsync();

            return(Result.Ok());
        }
Beispiel #2
0
        public async Task <Result> Put(int id, [FromBody] ProductAttributeParam model)
        {
            var productAttribute = await _productAttrRepository.FirstOrDefaultAsync(id);

            if (productAttribute == null)
            {
                return(Result.Fail("单据不存在"));
            }
            productAttribute.Name      = model.Name;
            productAttribute.GroupId   = model.GroupId;
            productAttribute.UpdatedOn = DateTime.Now;
            await _productAttrRepository.SaveChangesAsync();

            return(Result.Ok());
        }
        public async Task <string> QueryPagedAsync(Guid id, [FromQuery] ProductAttributeParam param)
        {
            param.ProductAttributeCategoryId = id;
            var filter = param.SearchLambda <ProductAttribute, ProductAttributeParam>();
            var result = await _productAttributeRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var pageData = new PagedDto <ProductAttribute>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
        public async Task <ApiRequestResult> QueryAsync([FromQuery] ProductAttributeParam param)
        {
            var result = await _productAttributeRepository.QueryAsync(c => c.ProductAttributeCategoryId == param.ProductAttributeCategoryId && c.Type == param.Type);

            return(ApiRequestResult.Success(result, ""));
        }