Beispiel #1
0
        public async Task <ServiceResponse <ProductGroupDto_ToReturn> > UpdateProductGroup(ProductGroupDto_ToUpdate productGroup, int id)
        {
            var oldProductGroup = await _dbContext.ProductGroups.FirstOrDefaultAsync(x => x.Id == id);

            if (productGroup != null)
            {
                oldProductGroup.IsActive = productGroup.IsActive;
                oldProductGroup.Name     = productGroup.Name;
                await _dbContext.SaveChangesAsync();

                return(ResponseResult.Success(_mapper.Map <ProductGroupDto_ToReturn>(await _dbContext.ProductGroups.FirstOrDefaultAsync(x => x.Id == id))));
            }
            else
            {
                return(ResponseResult.Failure <ProductGroupDto_ToReturn>("Not found product group id"));
            }
        }
Beispiel #2
0
 public async Task <IActionResult> UpdateProductGroup(ProductGroupDto_ToUpdate productGroup, int id)
 {
     return(Ok(await _productGroupService.UpdateProductGroup(productGroup, id)));
 }