コード例 #1
0
        public static void ConvertToProductOrderDetailEntity(ref ProductOrderDetail productOrderDetail, ProductOrderDtlDTO productOrderDtlDTO, bool isUpdate)
        {
            if (isUpdate)
            {
                productOrderDetail.DeliveredDate = productOrderDtlDTO.DeliveredDate;
                productOrderDetail.DeliveredBy   = productOrderDtlDTO.DeliveredBy;
                productOrderDetail.VehicleNumber = productOrderDtlDTO.VehicleNumber;
                productOrderDetail.DriverName    = productOrderDtlDTO.DriverName;
                productOrderDetail.DriverNumber  = productOrderDtlDTO.DriverNumber;
                productOrderDetail.JCBDriverName = productOrderDtlDTO.JCBDriverName;
                productOrderDetail.RoyaltyNumber = productOrderDtlDTO.RoyaltyNumber;
                productOrderDetail.ChalanNumber  = productOrderDtlDTO.ChallanNumber;
                productOrderDetail.OrderAddress  = productOrderDtlDTO.OrderAddress;
            }
            else
            {
                productOrderDetail.OrderId              = productOrderDtlDTO.OrderId;
                productOrderDetail.ProductMappingId     = productOrderDtlDTO.ProductMappingId;
                productOrderDetail.Quantity             = productOrderDtlDTO.Quantity;
                productOrderDetail.TotalPrice           = productOrderDtlDTO.TotalPrice;
                productOrderDetail.DeliveryExpectedDate = productOrderDtlDTO.DeliveryExpectedDate;
            }
            productOrderDetail.OrderStatus = (int)((OrderStatus)Enum.Parse(typeof(OrderStatus), productOrderDtlDTO.OrderStatus));

            productOrderDetail.Ref1 = productOrderDtlDTO.Ref1;
            productOrderDetail.Ref2 = productOrderDtlDTO.Ref2;
        }
コード例 #2
0
        public static ProductOrderDtlDTO ConvertToProductOrderDtlDto(ProductOrderDetail productOrderDetail)
        {
            ProductOrderDtlDTO productOrderDtlDTO = new ProductOrderDtlDTO();

            productOrderDtlDTO.ProductOrderDetailId = productOrderDetail.ProductOrderDetailId;
            productOrderDtlDTO.OrderId          = productOrderDetail.OrderId.GetValueOrDefault();
            productOrderDtlDTO.ProductMappingId = productOrderDetail.ProductMappingId.GetValueOrDefault();
            productOrderDtlDTO.Quantity         = productOrderDetail.Quantity.GetValueOrDefault();

            productOrderDtlDTO.TotalPrice = productOrderDetail.TotalPrice.GetValueOrDefault();

            productOrderDtlDTO.OrderStatus          = productOrderDetail.OrderStatus.ToString();
            productOrderDtlDTO.DeliveryExpectedDate = productOrderDetail.DeliveryExpectedDate;
            productOrderDtlDTO.DeliveredDate        = productOrderDetail.DeliveredDate.GetValueOrDefault();
            productOrderDtlDTO.DeliveredBy          = productOrderDetail.DeliveredBy;
            productOrderDtlDTO.VehicleNumber        = productOrderDetail.VehicleNumber;
            productOrderDtlDTO.DriverName           = productOrderDetail.DriverName;
            productOrderDtlDTO.DriverNumber         = productOrderDetail.DriverNumber;
            productOrderDtlDTO.JCBDriverNumber      = productOrderDetail.JCBDriverNumber;
            productOrderDtlDTO.RoyaltyNumber        = productOrderDetail.RoyaltyNumber;
            productOrderDtlDTO.OrderAddress         = productOrderDetail.OrderAddress;

            productOrderDtlDTO.Ref1 = productOrderDtlDTO.Ref1;
            productOrderDtlDTO.Ref2 = productOrderDtlDTO.Ref2;


            return(productOrderDtlDTO);
        }
コード例 #3
0
        public void AddProductOrder(ProductOrderDTO productOrderDTO)
        {
            ProductOrder productOrder = new ProductOrder();

            productOrder.OrderId     = unitOfWork.DashboardRepository.NextNumberGenerator("ProductOrder");
            productOrder.OrderNumber = "OD" + productOrder.OrderId.ToString();

            List <ProductOrderDetail> productOrderDetails = new List <ProductOrderDetail>();

            ProductOrderConvertor.ConvertToProductOrderEntity(ref productOrder, productOrderDTO, false);
            ProductOrderDetail productOrderDetail = new ProductOrderDetail();

            productOrderDetail.ProductOrderDetailId = unitOfWork.DashboardRepository.NextNumberGenerator("ProductOrderDetail");
            productOrderDetail.OrderId          = productOrder.OrderId;
            productOrderDetail.ProductMappingId = productOrderDTO.ProductMappingId;
            productOrderDetail.Quantity         = productOrderDTO.Quantity;
            productOrderDetail.OrderAddress     = productOrderDTO.OrderAddress;
            if (productOrderDTO.ExpectedDeliveryDate == DateTime.MinValue)
            {
                productOrderDetail.DeliveryExpectedDate = DateTime.Now.AddDays(10);
            }
            else
            {
                productOrderDetail.DeliveryExpectedDate = productOrderDTO.ExpectedDeliveryDate;
            }
            productOrderDetails.Add(productOrderDetail);
            productOrder.ProductOrderDetails = productOrderDetails;
            unitOfWork.ProductOrderRepository.Add(productOrder);
            unitOfWork.SaveChanges();
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: LeDuy1993/CS_Coffee
 public IActionResult Order(OrderCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         var order = new Order()
         {
             OrderId  = model.TableId,
             Using    = true,
             StarTime = DateTime.Now,
             EndTime  = DateTime.Now
         };
         var result = orderRepository.Edit(order);
         var pod    = new ProductOrderDetail()
         {
             ProductId            = model.ProductId,
             OrderDetailId        = model.OrderDetailId,
             ProductOrderDetailId = model.ProductOrderDetailId,
             Count = model.Count
         };
         var result2 = productOrderDetailRepository.Create(pod);
         if (result != null && result2 != null)
         {
             var url = "https://localhost:44366/Home/Index/" + model.TableId;
             return(Redirect(url));
         }
     }
     return(View());
 }
コード例 #5
0
 public void Add(ProductOrderDetail productOrderDetail)
 {
     if (productOrderDetail != null)
     {
         _repository.ProductOrderDetails.Add(productOrderDetail);
         //     _repository.SaveChanges();
     }
 }
コード例 #6
0
 public void Update(ProductOrderDetail productOrderDetail)
 {
     if (productOrderDetail != null)
     {
         _repository.Entry <Sql.ProductOrderDetail>(productOrderDetail).State = System.Data.Entity.EntityState.Modified;
         //     _repository.SaveChanges();
     }
 }
コード例 #7
0
        public ProductOrderDetail Edit(ProductOrderDetail productOrderDetail)
        {
            var editPOD = context.ProductOrderDetails.Attach(productOrderDetail);

            editPOD.State = EntityState.Modified;
            context.SaveChanges();
            return(productOrderDetail);
        }
コード例 #8
0
        public ProductOrderDetail GetByOrderId(int orderId)
        {
            ProductOrderDetail productOrderDetail = new ProductOrderDetail();

            productOrderDetail = _repository.ProductOrderDetails.FirstOrDefault(x => x.OrderId == orderId);



            return(productOrderDetail);
        }
コード例 #9
0
        public ActionResult Delete(int id)
        {
            ProductOrderDetail productOrder = _entities.ProductOrderDetails.SingleOrDefault(a => a.ProductID == id);

            if (productOrder != null)
            {
                TempData["ProductStatus"] = "This product was used by another user, so it is impossible to delete.";
            }
            return(View());
        }
コード例 #10
0
        public ProductOrderDetail Create(ProductOrderDetail model)
        {
            var newPod = new ProductOrderDetail()
            {
                ProductId            = model.ProductId,
                OrderDetailId        = model.OrderDetailId,
                Count                = model.Count,
                ProductOrderDetailId = model.ProductOrderDetailId
            };

            context.ProductOrderDetails.Add(newPod);
            context.SaveChanges();
            return(model);
        }
コード例 #11
0
ファイル: HomeController.cs プロジェクト: LeDuy1993/CS_Coffee
 public IActionResult Edit(OrderViewModel model)
 {
     if (ModelState.IsValid)
     {
         var productOD = new ProductOrderDetail()
         {
             ProductId            = model.ProductId,
             OrderDetailId        = model.OrderDetailId,
             Count                = model.Count,
             ProductOrderDetailId = model.PodId
         };
         if (productOrderDetailRepository.Edit(productOD) != null)
         {
             var url = "https://localhost:44366/Home/Index/" + model.OrderId;
             return(Redirect(url));
         }
     }
     return(View());
 }
コード例 #12
0
        public static ProductOrderDtlDTO ConvertToProductOrderDtlDto(ProductOrderDetail productOrderDetail)
        {
            ProductOrderDtlDTO productOrderDtlDTO = new ProductOrderDtlDTO();

            productOrderDtlDTO.ProductOrderDetailId = productOrderDetail.ProductOrderDetailId;
            productOrderDtlDTO.CustomerId           = productOrderDetail.ProductOrder.OrderCustomerId.GetValueOrDefault();
            productOrderDtlDTO.CustomerName         = productOrderDetail.ProductOrder.Customer.Name;

            productOrderDtlDTO.OrderId          = productOrderDetail.ProductOrder.OrderId;
            productOrderDtlDTO.OrderNumber      = productOrderDetail.ProductOrder.OrderNumber;
            productOrderDtlDTO.ProductMappingId = productOrderDetail.ProductMappingId.GetValueOrDefault();
            productOrderDtlDTO.ProductName      = productOrderDetail.ProductSiteMapping.Product.ProductName;
            productOrderDtlDTO.UnitPrice        = productOrderDetail.ProductSiteMapping.Product.ProductPrice.HasValue ? productOrderDetail.ProductSiteMapping.Product.ProductPrice.Value : 0;

            productOrderDtlDTO.Quantity        = productOrderDetail.Quantity.GetValueOrDefault();
            productOrderDtlDTO.OrderPrice      = productOrderDetail.ProductOrder.OrderPrice;
            productOrderDtlDTO.OrderTax        = productOrderDetail.ProductOrder.OrderTax.GetValueOrDefault();
            productOrderDtlDTO.CGSTTax         = productOrderDetail.ProductOrder.CGSTTax.GetValueOrDefault();
            productOrderDtlDTO.SGSTTax         = productOrderDetail.ProductOrder.SGSTTax.GetValueOrDefault();
            productOrderDtlDTO.OrderDiscount   = productOrderDetail.ProductOrder.OrderDiscount.GetValueOrDefault();
            productOrderDtlDTO.OrderAmountPaid = productOrderDetail.ProductOrder.OrderPaidAmount.GetValueOrDefault();
            productOrderDtlDTO.TotalPrice      = productOrderDetail.ProductOrder.OrderTotalPrice.GetValueOrDefault();

            productOrderDtlDTO.OrderStatus          = productOrderDetail.OrderStatus.ToString();
            productOrderDtlDTO.DeliveryExpectedDate = productOrderDetail.DeliveryExpectedDate;
            productOrderDtlDTO.DeliveredDate        = productOrderDetail.DeliveredDate.GetValueOrDefault();
            productOrderDtlDTO.DeliveredBy          = productOrderDetail.DeliveredBy;
            productOrderDtlDTO.VehicleNumber        = productOrderDetail.VehicleNumber;
            productOrderDtlDTO.DriverName           = productOrderDetail.DriverName;
            productOrderDtlDTO.DriverNumber         = productOrderDetail.DriverNumber;
            productOrderDtlDTO.JCBDriverName        = productOrderDetail.JCBDriverName;
            productOrderDtlDTO.RoyaltyNumber        = productOrderDetail.RoyaltyNumber;

            productOrderDtlDTO.ChallanNumber = productOrderDetail.ChalanNumber;
            productOrderDtlDTO.OrderAddress  = productOrderDetail.OrderAddress;

            productOrderDtlDTO.Ref1 = productOrderDetail.Ref1;
            productOrderDtlDTO.Ref2 = productOrderDetail.Ref2;


            return(productOrderDtlDTO);
        }
コード例 #13
0
        public void UpdateProductOrder(ProductOrderDTO productOrderDTO)
        {
            ProductOrder productOrder = unitOfWork.ProductOrderRepository.GetById(productOrderDTO.OrderId);

            ProductOrderDetail productOrderDetail = unitOfWork.ProductOrderDtlRepository.GetByOrderId(productOrderDTO.OrderId);



            if (string.IsNullOrWhiteSpace(productOrderDTO.OrderAddress) == false)
            {
                productOrderDetail.OrderAddress = productOrderDTO.OrderAddress;
            }

            if (string.IsNullOrWhiteSpace(productOrderDTO.OrderComments) == false)
            {
                productOrder.OrderComments = productOrderDTO.OrderComments;
            }

            if (string.IsNullOrWhiteSpace(productOrderDTO.OrderPriority) == false)
            {
                productOrder.OrderPriority = productOrderDTO.OrderPriority;
            }

            if (productOrderDTO.ExpectedDeliveryDate != DateTime.MinValue)
            {
                productOrderDetail.DeliveryExpectedDate = productOrderDTO.ExpectedDeliveryDate;
            }

            if (productOrderDTO.Quantity > 0)
            {
                productOrderDetail.Quantity = productOrderDTO.Quantity;
            }
            unitOfWork.ProductOrderRepository.Update(productOrder);
            unitOfWork.ProductOrderDtlRepository.Update(productOrderDetail);

            unitOfWork.SaveChanges();
        }
コード例 #14
0
        public void AddToProductOrders(FormCollection collection, int productOrderID)
        {
            ProductOrder productOrder = _entities.ProductOrders.SingleOrDefault(a => a.ID == productOrderID);
            List <ProductOrderDetail> productOrderDetails = _entities.ProductOrderDetails.Where(a => a.ProductOrderID == productOrderID).ToList();
            List <int> productIDs = productOrderDetails.Select(a => a.ProductID).ToList();

            //if (selectedProductIDs == null)
            //{
            //    List<int> temp = new List<int>();
            //    foreach (Product product in viewModel)
            //    {
            //        temp.Add(product.ID);
            //    }
            //    selectedProductIDs = temp.AsEnumerable();
            //}

            string[] keys = collection.AllKeys;
            for (int i = 1; i < keys.Length - 1; i++)            //Remove DropDownList [0] and buttom [Length]
            {
                string temp      = collection.Get(keys[i].ToString());
                int    productID = int.Parse(keys[i]);
                if (!string.IsNullOrEmpty(temp) && temp.ToLower().StartsWith("true") && !productIDs.Contains(productID))
                {
                    ProductOrderDetail pod = new ProductOrderDetail();
                    pod.ProductID = productID;
                    productOrder.ProductOrderDetails.Add(pod);
                }
                else if (!string.IsNullOrEmpty(temp) && temp.ToLower().StartsWith("false") && productIDs.Contains(productID))
                {
                    ProductOrderDetail pod = _entities.ProductOrderDetails.SingleOrDefault(a => a.ProductID == productID && a.ProductOrderID == productOrderID);
                    _entities.DeleteObject(pod);
                }
            }
            UpdateModel(productOrder, "ProductOrder");
            _entities.SaveChanges();
        }
コード例 #15
0
 public void Delete(ProductOrderDetail entity)
 {
     _productOrderDetailRepository.Delete(entity);
 }
コード例 #16
0
        /// <summary>
        /// 新增定单
        /// </summary>
        /// <param name="orderProduct"></param>
        /// <param name="isShoppingCart"></param>
        /// <param name="productOrder"></param>
        /// <param name="addressID"></param>
        /// <returns></returns>
        public StateCode Save(List <JsonOrderProduct> orderProduct, ProductOrder productOrder, long addressID, bool isShoppingCart)
        {
            string  freight_str    = "";
            decimal freight        = 0;
            long    deliveryModeID = 0;

            //如果是自提则不计算运费
            if (productOrder.logistic_method == 0)
            {
                StateCode code = ServiceIoc.Get <DeliveryModeService>().GetDefaultFreight(orderProduct, addressID, out freight_str);
                if (code != StateCode.State_200)
                {
                    return(code);
                }
                //运费
                freight = decimal.Parse(freight_str.Split('#')[1]);
                //运费模板ID
                deliveryModeID = int.Parse(freight_str.Split('#')[0]);
            }

            using (ISession s = SessionFactory.Instance.CreateSession())
            {
                try
                {
                    s.StartTransaction();

                    //订单商品较验
                    foreach (var op in orderProduct)
                    {
                        //较验商品规格是否存在
                        ProductSku sku = s.Get <ProductSku>("where product_id = @0 and dbo.fn_check_specset(specset,@1) = 1 ", op.product_id, op.specset);
                        if (sku == null)
                        {
                            productOrder = null;
                            s.RollBack();
                            return(StateCode.State_1);
                        }

                        //较验商品是否存在
                        Product product = s.Get <Product>("where id = @0 ", sku.product_id);
                        if (product == null)
                        {
                            productOrder = null;
                            s.RollBack();
                            return(StateCode.State_1);
                        }

                        //较验商品库存
                        if (op.qty > sku.stock)
                        {
                            productOrder = null;
                            s.RollBack();
                            return(StateCode.State_502);
                        }

                        //较验商品状态
                        if (!((bool)product.is_shelves && !(bool)product.is_delete && (DateTime.Now > product.shelves_sdate && DateTime.Now < product.shelves_edate)))
                        {
                            productOrder = null;
                            s.RollBack();
                            return(StateCode.State_505);
                        }

                        //商品库存处理
                        sku.stock = sku.stock - op.qty;
                        s.Update <ProductSku>(sku);
                    }

                    //创建订单
                    productOrder.serial_no        = AlgorithmHelper.CreateNo();
                    productOrder.status           = OrderStatus.WaitingPayment;
                    productOrder.delete_status    = 0;
                    productOrder.created_date     = DateTime.Now;
                    productOrder.total_amount     = 0;
                    productOrder.actual_amount    = 0;
                    productOrder.cost_price       = 0;
                    productOrder.delivery_mode_id = deliveryModeID;
                    s.Insert <ProductOrder>(productOrder);

                    //总金额,成本价,优惠卷金额
                    decimal totalProdutPrice = 0, costProdutPrice = 0;

                    //商品的总重量,包邮商品的总重量
                    int total_weight = 0, sum_total_weight = 0;

                    int index = 0;

                    foreach (var op in orderProduct)
                    {
                        //商品规格
                        ProductSku sku = s.Get <ProductSku>("where product_id = @0 and dbo.fn_check_specset(specset,@1) = 1", op.product_id, op.specset);
                        //商品
                        Product product = s.Get <Product>(sku.product_id);

                        string[]      arr      = StringHelper.StringToArray(sku.specset);
                        StringBuilder specinfo = new StringBuilder();
                        foreach (string i in arr)
                        {
                            int specname_id  = 0;
                            int specvalue_id = 0;
                            if (i.IndexOf("_") != -1)
                            {
                                int.TryParse(i.Split('_')[0], out specname_id);
                                int.TryParse(i.Split('_')[1], out specvalue_id);

                                SpecName  specname  = s.Get <SpecName>("where id = @0 ", specname_id);
                                SpecValue specvalue = s.Get <SpecValue>("where id = @0 ", specvalue_id);

                                if (specname != null && specvalue != null)
                                {
                                    specinfo.Append(string.Format("{0}:{1}; ", specname.name, specvalue.val));
                                }
                                else
                                {
                                    throw new Exception("商品规格信息异常");
                                }
                            }
                        }

                        //当前当商品成本
                        decimal cost_sum = sku.cost_price * op.qty;

                        //押金
                        decimal sum = sku.sale_price * op.qty;

                        totalProdutPrice += sum;
                        costProdutPrice  += cost_sum;

                        //该商品是否包邮
                        if (!product.is_postage)
                        {
                            sum_total_weight += sku.weight * op.qty;
                        }

                        //计算重量
                        total_weight += sku.weight * op.qty;

                        //获取产品主图片
                        string     mainPic  = "";
                        List <Img> pictures = s.List <Img>("where biz_type = @0 and biz_id = @1", ImgType.Product_Cover, product.id);
                        Img        img      = pictures.Where(p => p.is_main).SingleOrDefault();
                        if (img != null)
                        {
                            mainPic = img.is_webimg ? img.webimg_url : img.getThmImgUrl();
                        }

                        //创建订单明细
                        ProductOrderDetail orderDetail = new ProductOrderDetail()
                        {
                            order_id        = productOrder.id,
                            product_id      = product.id,
                            specset         = op.specset,
                            product_name    = product.name,
                            product_en_name = product.en_name,
                            product_img_url = mainPic,
                            spec_msg        = specinfo.ToString().Trim(),
                            unit_price      = sku.sale_price,
                            count           = op.qty,
                            total_weight    = sku.weight * op.qty,
                            order_index     = ++index,
                            cost_price      = cost_sum,
                            total_amount    = sum,
                            actual_amount   = sum
                        };
                        s.Insert(orderDetail);

                        //购物车删除商品
                        if (isShoppingCart)
                        {
                            s.ExcuteUpdate("delete tb_ord_shoppingcart where user_id = @0 and product_id = @1 and dbo.fn_check_specset(specset,@2) = 1", productOrder.created_user_id, orderDetail.product_id, orderDetail.specset ?? "");
                        }
                    }

                    #region 会员折扣模块

                    //会员折扣优惠金额
                    decimal discount = 0;
                    //累计消费金额
                    object user_total_amount = s.ExecuteScalar("select COALESCE(SUM(total_amount),0) from tb_odr_order where created_user_id = @0 and is_pay = @1", productOrder.created_user_id, true);
                    //累计消费金额
                    decimal amount = decimal.Parse(user_total_amount.ToString());

                    //获取等级列表
                    List <MemberLevelSetting> levels = s.List <MemberLevelSetting>("order by total_amount desc");
                    foreach (var level in levels)
                    {
                        if (amount >= level.total_amount)
                        {
                            discount = totalProdutPrice * (100 - level.discount) / 100;
                            break;
                        }
                    }

                    //会员折扣
                    productOrder.discount_amount = discount;
                    #endregion

                    #region 优惠卷模块

                    if (productOrder.user_coupon_id != 0)
                    {
                        //存在未使用的优惠卷
                        string     coupon_sql = "where id = @0 and is_used = @1 and full_amount <= @2";
                        UserCoupon userCoupon = s.Get <UserCoupon>(coupon_sql, productOrder.user_coupon_id, false, totalProdutPrice);
                        if (userCoupon != null)
                        {
                            //优惠卷金额
                            productOrder.coupon_amount = userCoupon.coupon_amount;
                            //修改会员优惠卷状态
                            s.ExcuteUpdate("update tb_user_aty_coupon set is_used = @0 where id = @1", true, userCoupon.id);
                        }
                    }

                    #endregion

                    #region 发货单

                    ShoppingAddress sa = s.Get <ShoppingAddress>(addressID);
                    if (sa == null)
                    {
                        throw new Exception("收货地址不存在");
                    }

                    //订单发货信息
                    OrderDelivery orderDelivery = new OrderDelivery();
                    orderDelivery.order_id    = productOrder.id;
                    orderDelivery.province    = sa.province;
                    orderDelivery.city        = sa.city;
                    orderDelivery.area        = sa.area;
                    orderDelivery.address     = sa.address;
                    orderDelivery.contact     = sa.contact;
                    orderDelivery.mobile      = sa.mobile;
                    orderDelivery.postal_code = sa.postal_code;
                    orderDelivery.tel         = sa.tel;

                    s.Insert <OrderDelivery>(orderDelivery);
                    #endregion

                    //总计金额(商品总金额+物流费用)
                    var totalPrice = totalProdutPrice + freight;
                    //成本价
                    productOrder.cost_price = costProdutPrice;
                    //配送费
                    productOrder.freight = freight;
                    //总金额
                    productOrder.total_amount = totalPrice;
                    //实付金额
                    productOrder.actual_amount = totalPrice - productOrder.coupon_amount - discount;
                    //总重量
                    productOrder.total_weight = total_weight;
                    //更新订单
                    s.Update <ProductOrder>(productOrder);

                    s.Commit();

                    return(StateCode.State_200);
                }
                catch (Exception ex)
                {
                    s.RollBack();
                    return(StateCode.State_500);
                }
            }
        }
コード例 #17
0
        public void AddProductOrderDtl(ProductOrderDtlDTO productOrderDtlDTO)
        {
            this.CalculateOrderAmount(productOrderDtlDTO);
            this.CalcualteOrderTax(productOrderDtlDTO);
            ProductOrderDetail productOrderDetail = unitOfWork.ProductOrderDtlRepository.GetById(productOrderDtlDTO.ProductOrderDetailId);

            if (productOrderDetail != null)
            {
                productOrderDetail.ProductMappingId = productOrderDtlDTO.ProductMappingId;
                if (productOrderDtlDTO.Quantity > 0)
                {
                    productOrderDetail.Quantity = productOrderDtlDTO.Quantity;
                }

                if (productOrderDtlDTO.OrderPrice > 0)
                {
                    productOrderDetail.TotalPrice = productOrderDtlDTO.OrderPrice;
                }

                if (string.IsNullOrWhiteSpace(productOrderDtlDTO.OrderStatus) == false)
                {
                    productOrderDetail.OrderStatus = (int)((OrderStatus)Enum.Parse(typeof(OrderStatus), productOrderDtlDTO.OrderStatus));
                }

                if (string.IsNullOrWhiteSpace(productOrderDtlDTO.VehicleNumber) == false)
                {
                    productOrderDetail.VehicleNumber = productOrderDtlDTO.VehicleNumber;
                }

                if (string.IsNullOrWhiteSpace(productOrderDtlDTO.DriverName) == false)
                {
                    productOrderDetail.DriverName = productOrderDtlDTO.DriverName;
                }

                if (string.IsNullOrWhiteSpace(productOrderDtlDTO.DriverNumber) == false)
                {
                    productOrderDetail.DriverNumber = productOrderDtlDTO.DriverNumber;
                }

                if (string.IsNullOrWhiteSpace(productOrderDtlDTO.JCBDriverName) == false)
                {
                    productOrderDetail.JCBDriverName = productOrderDtlDTO.JCBDriverName;
                }

                if (string.IsNullOrWhiteSpace(productOrderDtlDTO.RoyaltyNumber) == false)
                {
                    productOrderDetail.RoyaltyNumber = productOrderDtlDTO.RoyaltyNumber;
                }

                if (string.IsNullOrWhiteSpace(productOrderDtlDTO.ChallanNumber) == false)
                {
                    productOrderDetail.ChalanNumber = productOrderDtlDTO.ChallanNumber;
                }


                if (string.IsNullOrWhiteSpace(productOrderDtlDTO.DeliveredBy) == false)
                {
                    productOrderDetail.DeliveredBy = productOrderDtlDTO.DeliveredBy;
                }

                if (productOrderDetail.DeliveredDate != DateTime.MinValue)
                {
                    productOrderDetail.DeliveredDate = productOrderDtlDTO.DeliveredDate;
                }

                unitOfWork.ProductOrderDtlRepository.Update(productOrderDetail);

                //Update product Order for tax and total price
                ProductOrder productOrder = unitOfWork.ProductOrderRepository.GetById(productOrderDtlDTO.OrderId);
                productOrder.OrderPrice      = productOrderDtlDTO.OrderPrice;
                productOrder.OrderTax        = productOrderDtlDTO.OrderTax;
                productOrder.CGSTTax         = productOrderDtlDTO.CGSTTax;
                productOrder.SGSTTax         = productOrderDtlDTO.SGSTTax;
                productOrder.OrderDiscount   = productOrderDtlDTO.OrderDiscount;
                productOrder.OrderPaidAmount = productOrderDtlDTO.OrderAmountPaid;
                productOrder.OrderTotalPrice = productOrderDtlDTO.TotalPrice - productOrderDtlDTO.OrderDiscount;
                unitOfWork.ProductOrderRepository.Update(productOrder);

                this.AddOrUpdateProductSales(productOrderDtlDTO);
                this.AddCustomerPayment(productOrderDtlDTO);
                this.AddOrUpdateCustomerWallet(productOrderDtlDTO);
                unitOfWork.SaveChanges();
            }
        }
コード例 #18
0
 public void Insert(ProductOrderDetail entity)
 {
     _productOrderDetailRepository.Add(entity);
 }
コード例 #19
0
 public void Update(ProductOrderDetail entity)
 {
     _productOrderDetailRepository.Update(entity);
 }