Beispiel #1
0
        private async Task <BaseResult> Update(DiscountOrder discountOrder, int updateBy = 0, string updateByUserName = "")
        {
            var result = new BaseResult()
            {
                Result = Result.Success
            };
            var discountOrderForUpdate = _discountOrderRepository.Query().FirstOrDefault(p => p.Id == discountOrder.Id);

            if (discountOrderForUpdate == null || discountOrder.Id <= 0)
            {
                result.Result  = Result.Failed;
                result.Message = "Không tìm thấy";
                return(result);
            }
            try
            {
                discountOrderForUpdate = discountOrder.ToDiscountOrder(discountOrderForUpdate);

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

                await _discountOrderRepository.UpdateAsync(discountOrderForUpdate);
            }
            catch (Exception e)
            {
                result.Result  = Result.SystemError;
                result.Message = e.ToString();
            }
            return(result);
        }
Beispiel #2
0
        public string BuyProduct(Order _order, DiscountOrder _discountOrder, int _amountOfProduct, int _discountCardNumber)
        {
            if (_discountCardNumber == 0)
            {
                _order.AmountOfProduct    = _amountOfProduct;
                _order.DateTimeOfPurchase = DateTime.Now;


                new CRUD().SaveOrder(_order);
                new CRUD().UpdateCountInProduct(_order.ProductId, _order.AmountOfProduct);
            }

            else
            {
                if (!new AuxiliaryFunctions().IsDiscountCardNumberExist(_discountCardNumber))
                {
                    return("Card does not exist");
                }

                Customer _customer1 = new CRUD().GetOneCustomerByDiscountCardNumber(_discountCardNumber);
                _discountOrder.UserId             = _customer1.CustomerId;
                _discountOrder.CountOfProduct     = _amountOfProduct;
                _discountOrder.DateTimeOfPurchase = DateTime.Now;

                new CRUD().SaveDiscountOrder(_discountOrder);
                new CRUD().UpdateCountInProduct(_discountOrder.ProductId, _discountOrder.CountOfProduct);
            }
            return("Save");
        }
Beispiel #3
0
 public void SaveDiscountOrder(DiscountOrder _order)
 {
     using (CoffeeShopContext db = new CoffeeShopContext())
     {
         db.DiscountOrders.Add(_order);
         db.SaveChanges();
     }
 }
Beispiel #4
0
        private async Task <BaseResult> Create(DiscountOrder discountOrder)
        {
            var result = new BaseResult();

            discountOrder.DiscountId = discountOrder.DiscountId;
            try
            {
                await _discountOrderRepository.InsertAsync(discountOrder);
            }
            catch (Exception e)
            {
                result.Result  = Result.SystemError;
                result.Message = e.ToString();
            }
            return(result);
        }
        private void ContentOnAfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs documentCacheEventArgs)
        {
            //if (sender.ContentType.Alias.StartsWith("uwbs") && sender.ContentType.Alias != Order.NodeAlias)
            //todo: work with aliasses from config
            var alias = sender.ContentType.Alias;

            // todo: make a nice way for this block
            if (Product.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (ProductVariant.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (Category.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (PaymentProvider.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (PaymentProviderMethod.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (DiscountProduct.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (DiscountOrder.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (ShippingProvider.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (ShippingProviderMethod.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (Store.IsAlias(alias))
            {
                ResetAll(sender.Id, alias);
            }
            else if (alias.StartsWith("uwbs") && alias != Order.NodeAlias)
            {
                ResetAll(sender.Id, alias);
            }

            var storePickerProperty = sender.getProperty(Constants.StorePickerAlias);

            if (storePickerProperty != null)
            {
                int storeId;
                if (storePickerProperty.Value != null && int.TryParse(storePickerProperty.Value.ToString(), out storeId))
                {
                    var storeService = StoreHelper.StoreService;
                    var storeById    = storeService.GetById(storeId, null);
                    if (storeById != null)
                    {
                        storeService.TriggerStoreChangedEvent(storeById);
                    }
                }
            }

            if (alias.StartsWith(Settings.NodeAlias))
            {
                IO.Container.Resolve <ISettingsService>().TriggerSettingsChangedEvent(SettingsLoader.GetSettings());
            }

            if (alias.StartsWith(Store.NodeAlias))
            {
                //todo: naar nieuwe v6+ API omzetten
                var storeService = StoreHelper.StoreService;
                storeService.TriggerStoreChangedEvent(storeService.GetById(sender.Id, null));
                var node = new Node(sender.Id);
                if (!sender.Text.Equals(node.Name))
                {
                    StoreHelper.RenameStore(node.Name, sender.Text);
                }
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            Goods java = new Goods();

            java.Name  = "java";
            java.Num   = 10;
            java.Price = 9.5;
            Goods csharp = new Goods();

            csharp.Name  = "csharp";
            csharp.Num   = 4;
            csharp.Price = 5.5;
            Goods python = new Goods();

            python.Name  = "python";
            python.Num   = 7;
            python.Price = 7.5;
            DiscountOrder discountOrder = new DiscountOrder(0.5);

            discountOrder.add(csharp);
            discountOrder.add(java);
            FullReductionOrder fullReductionOrder = new FullReductionOrder();

            fullReductionOrder.add(python);

            AccountBook accountBook = new AccountBook();

            accountBook.add(discountOrder);
            accountBook.add(fullReductionOrder);

            Console.WriteLine("合计 {0}", accountBook.totalPrice());

            /*Scence scence = new Scence(20, 20);
             * player player = new player(scence, 1, 1);
             * player player2 = new player("永恩", 100, 50, 5, 10);
             * Enemy enemy = new Enemy("亚索", 100, 50, 5, 10);
             * //是否刷新
             * bool isFlush = true;
             * Console.WriteLine("游戏开始!");
             * player2.Print();
             * enemy.Print();
             * while (isStart)
             * {
             *  Console.WriteLine("请输入a,q,r攻击,按w退出");
             *  char keyChar = Console.ReadKey().KeyChar;
             *  if (keyChar == 'w')
             *  {
             *      isStart = false;
             *  }
             *  else
             *  {
             *      player2.Handle(keyChar, enemy);
             *      if (enemy.Hp < 0)
             *      {
             *          Console.WriteLine("你获得了胜利!");
             *          break;
             *      }
             *      enemy.randomHandle(player2);
             *      if (player2.Hp < 0)
             *      {
             *          Console.WriteLine("胜败乃兵家常事!");
             *          break;
             *      }
             *
             *  }*/
            /*if (isFlush)
             * {
             *  scence.Print(player);
             *  Console.WriteLine("游戏开始,请输入w,a,s,d移动,按q退出");
             * }
             * char keyChar = Console.ReadKey().KeyChar;
             * if (keyChar == 'q')
             * {
             *  isStart = false;
             * }
             * else
             * {
             *  isFlush = player.move(keyChar);
             *
             * }*/
            /*}*/
        }
 public static DiscountOrder ToDiscountOrder(this DiscountOrder entity, DiscountOrder destination)
 {
     return(entity.MapTo(destination));
 }
 public static DiscountOrderItem ToItem(this DiscountOrder entity)
 {
     return(entity.MapTo <DiscountOrder, DiscountOrderItem>());
 }
 public static DiscountOrderModel ToModel(this DiscountOrder entity)
 {
     return(entity.MapTo <DiscountOrder, DiscountOrderModel>());
 }