예제 #1
0
        private async Task <BaseResult> Update(ProductImage ProductImage)
        {
            var result = new BaseResult()
            {
                Result = Result.Success
            };
            var ProductImageForUpdate = _ProductImageRepository.Query().FirstOrDefault(p => p.Id == ProductImage.Id);

            if (ProductImageForUpdate == null)
            {
                result.Result  = Result.Failed;
                result.Message = "Không tìm thấy sản phẩm liên quan yêu cầu!";
                return(result);
            }
            try
            {
                ProductImageForUpdate = ProductImage.ToProductImage(ProductImageForUpdate);

                //Cập nhật thông tin chung của thực thể
                ProductImageForUpdate = ProductImageForUpdate.UpdateCommonInt();

                await _ProductImageRepository.UpdateAsync(ProductImageForUpdate);
            }
            catch (Exception e)
            {
                result.Result  = Result.SystemError;
                result.Message = e.ToString();
            }
            return(result);
        }