public async Task <BaseResult> Create(Domain.Orders.Order_Item orderitem)
        {
            var rs = new BaseResult()
            {
                Result = Result.Success
            };

            //var productpiece = _productpieceService.Get(orderitem.ProductPieceId);
            // var product = _productService.Get(productpiece.ProductId);
            //orderitem.Price = product.Price;
            orderitem.Price = 6969669;


            try
            {
                await _Repository.InsertAsync(orderitem);

                var orderForUpdate = _orderRepository.Query().FirstOrDefault(p => p.Id == orderitem.OrderId);
                orderForUpdate.value = (int)this.GetValue(orderForUpdate.Id);
                rs.Message           = GetValue(orderitem.OrderId).ToString();
                await _orderRepository.UpdateAsync(orderForUpdate);

                _orderRepository.SaveChange();
            }
            catch (Exception ex)
            {
                rs.Result  = Result.SystemError;
                rs.Message = ex.ToString();
            }
            return(rs);
        }
        public async Task <BaseResult> Update(Domain.Orders.Order_Item orderitem, int updateBy = 0, string updateByUserName = "")
        {
            var rs = new BaseResult()
            {
                Result = Result.Success
            };
            var orderForUpdate = _Repository.Query().FirstOrDefault(p => p.Id == orderitem.Id);

            if (orderForUpdate != null)
            {
                try
                {
                    orderForUpdate = orderitem.ToOrderItem(orderForUpdate);

                    orderForUpdate = orderForUpdate.UpdateCommonInt(updateBy, updateByUserName);
                    await _Repository.UpdateAsync(orderForUpdate);

                    var orderForUpdate2 = _orderRepository.Query().FirstOrDefault(p => p.Id == orderitem.OrderId);
                    orderForUpdate2.value = this.GetValue(orderForUpdate.Id);
                    await _orderRepository.UpdateAsync(orderForUpdate2);

                    _orderRepository.SaveChange();
                    _Repository.SaveChange();
                }
                catch (Exception ex)
                {
                    rs.Result  = Result.SystemError;
                    rs.Message = ex.ToString();
                }
            }
            else
            {
                rs.Message = "Không tìm thấy don hang cần sửa";
                rs.Result  = Result.Failed;
            }
            return(rs);
        }
 public static Domain.Orders.Order_Item ToOrderItem(this Domain.Orders.Order_Item entity, Domain.Orders.Order_Item destination)
 {
     return(entity.MapTo(destination));
 }
 public static Items.Orders.OrderItemItem ToItem(this Domain.Orders.Order_Item entity)
 {
     return(entity.MapTo <Domain.Orders.Order_Item, Items.Orders.OrderItemItem>());
 }