Ejemplo n.º 1
0
 public IActionResult SaleOrderInsert(SaleOrder model)
 {
     if (ModelState.IsValid)
     {
         model.SOId   = Guid.NewGuid().ToString();
         model.Status = Status.Pending.ToString();
         collectionSaleOrder.Create(model);
     }
     ModelState.Clear();
     return(RedirectToAction("SaleOrderInsert"));
 }
Ejemplo n.º 2
0
        private void SaveSaleOrder(DataType.SaleOrderStatus saleOrderStatus = DataType.SaleOrderStatus.NotBalanced)
        {
            _saleOrder.HowBalance = RadBanlanceModeCash.IsChecked.HasValue && RadBanlanceModeCash.IsChecked.Value
                    ? (SByte)DataType.SaleOrderBalancedMode.Cash
                    : RadBanlanceModeCard.IsChecked.HasValue && RadBanlanceModeCard.IsChecked.Value
                        ? (SByte)DataType.SaleOrderBalancedMode.MemberCard
                        : (SByte)DataType.SaleOrderBalancedMode.UnitUnionPay;

            _soProduceDomainModels.ForEach(
                x =>
            {
                x.SOProduce.RetailPrice             = x.SOProduce.Produce.RetailPrice;
                x.SOProduce.SOProduceStatusCategory = (sbyte)saleOrderStatus;
            });
            _saleOrder.FavorableCost     = _balanceDomainModel.DiscountPrice;
            _saleOrder.UserRealPrice     = _balanceDomainModel.RealPrice;
            _saleOrder.UserReturnedPrice = _balanceDomainModel.ReturnedPrice;
            _saleOrder.ProduceCost       = _soProduceDomainModels.Sum(x => x.SOProduce.Quantity * x.CostPerUnit);
            _saleOrder.TotalCost         = (_saleOrder.OtherCost ?? 0) + _saleOrder.ProduceCost;
            _saleOrder.SaleOrderStatus   = (sbyte)saleOrderStatus;

            if (_saleOrder.SaleOrderId == 0)
            {
                CommonHelper.AddCreatedOnAndDate(ResourcesHelper.CurrentUser, _saleOrder);
                _soProduceDomainModels.ForEach(x => CommonHelper.AddCreatedOnAndDate(ResourcesHelper.CurrentUser, x.SOProduce));
                _saleOrder.SOProduces = _soProduceDomainModels.Select(x => x.SOProduce).ToList();
                _saleOrderRepository.Create(_saleOrder);
            }
            else
            {
                CommonHelper.UpdateModifiedOnAndDate(ResourcesHelper.CurrentUser, _saleOrder);
                _soProduceDomainModels.ForEach(x => CommonHelper.AddCreatedOnAndDate(ResourcesHelper.CurrentUser, x.SOProduce));
                _saleOrder.SOProduces = _soProduceDomainModels.Select(x => x.SOProduce).ToList();
                _saleOrderRepository.Update(_saleOrder);
            }

            _saleOrder.SaleOrderStatus = (sbyte)saleOrderStatus;
        }