Exemplo n.º 1
0
        public async Task <ActionResult> Detail(Guid?id, int page = 1)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            var u = await UserFacade.GetUserAccordingToUsernameAsync(User.Identity.Name);

            var lowerBound = u.Character.Level - 2;
            var upperBound = lowerBound + 4;
            var shop       = await ShopFacade.GetAsync(id.GetValueOrDefault());

            var list = new List <ItemDto>(shop.Items.Where(i => i.RequiredLevel >= lowerBound && i.RequiredLevel <= upperBound).ToList());

            ViewBag.Count   = list.Count;
            ViewBag.Current = page;

            shop.Items = list.OrderByDescending(a => a.Quality).ThenByDescending(a => a.RequiredLevel).Skip((page - 1) * 12).Take(12).ToList();
            var model = new ShopCharacterModel()
            {
                Character = u.Character, Shop = shop
            };

            return(View(model));
        }
Exemplo n.º 2
0
 public static ShopFacade getInstance()
 {
     if (Inst == null)
     {
         Inst = new ShopFacade();
     }
     return(Inst);
 }
Exemplo n.º 3
0
        private void validateAddNewProduct(IEnumerable <ProductInfo> allProducts, ProductInfo newProduct, IEnumerable <ProductInfo> expected)
        {
            var actual = allProducts.ToList();
            var sut    = new ShopFacade();

            sut.AddNewProduct(actual, newProduct);
            expected.Should().BeEquivalentTo(actual);
        }
Exemplo n.º 4
0
        // GET: Shop
        public async Task <ActionResult> Index()
        {
            var u = await UserFacade.GetUserAccordingToUsernameAsync(User.Identity.Name);

            if (u.Character == null)
            {
                return(RedirectToAction("Detail", "User"));
            }

            var list = await ShopFacade.GetAllAsync();

            return(View(list));
        }
Exemplo n.º 5
0
    private void OnClickBuy(EventContext context)
    {
        var id     = (int)(context.sender as GObject).data;
        var deploy = WantSellDeploy.GetInfo(id);

        var itemData = new ItemData();

        itemData.Name  = Data.Name;
        itemData.Value = deploy.Value;
        itemData.Id    = Data.Id;
        itemData.Type  = Data.Type;
        itemData.Count = 1;
        ShopFacade.getInstance().SellGoods(itemData);
        Hide();
    }
Exemplo n.º 6
0
 private void OnSell(EventContext context)
 {
     if (Data.Type == EGoodsType.WuXue)
     {
         WinCenter.inst.ShowPanel <UIGainSkill>(Data, 1);
     }
     else
     {
         var itemData = new ItemData();
         itemData.Name  = Data.Name;
         itemData.Value = Data.Value;
         itemData.Id    = Data.Id;
         itemData.Type  = Data.Type;
         itemData.Count = 1;
         ShopFacade.getInstance().SellGoods(itemData);
     }
 }
Exemplo n.º 7
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <PlayerContext>().UseInMemoryDatabase(databaseName: "PlayerList").Options;

            Database = new PlayerContext(options);
            Command  = new List <ICommand>();
            Player   = new Player {
                health_points = 100, Name = "Julius", speed = 10, PosX = 100, PosY = 100
            };
            Weapon = new Weapon {
                PlayerID = 0, cost = 100, damage = 75
            };
            Command.Add(new UpCommand(Player));
            Command.Add(new DownCommand(Player));
            Command.Add(new LeftCommand(Player));
            Command.Add(new RightCommand(Player));
            ObsFactory     = new ObsticaleFacotry();
            WeaponsFacotry = new WeaponsFacotry();
            Shop           = new ShopFacade();
        }
Exemplo n.º 8
0
 static void Main(string[] args)
 {
     ShopFacade.Instance().buyProductByCashWithFreeShipping("*****@*****.**");
     ShopFacade.Instance().buyProductByPaypalWithStandardShipping("*****@*****.**");
 }