Ejemplo n.º 1
0
 private Receipt(ShopEnum shop, List <Item> items) : this()
 {
     ShopEnum     = shop;
     Items        = items;
     Total        = Items.Sum(item => item.Prices[(int)ShopEnum]); // slower than foreach
     PurchaseTime = DateTime.Now;
 }
Ejemplo n.º 2
0
    public bool IsAvailableForBuying(ShopEnum type, int id, int stock)
    {
        UpdateShopDict();
        if (stock == -1)
        {
            return(true);
        }
        var data = shopDic[type];

        return(GetBoughtCount(type, id) < stock);
    }
Ejemplo n.º 3
0
 public static void Switch(ShopEnum shop)
 {
     foreach (ShopProfile sp in Shops)
     {
         if (sp.Shop == shop)
         {
             _current = sp;
             break;
         }
     }
 }
Ejemplo n.º 4
0
    public void AddBought(ShopEnum type, int id)
    {
        UpdateShopDict();
        var data = shopDic[type];

        if (data.ContainsKey(id))
        {
            data[id] += 1;
        }
        else
        {
            data.Add(id, 1);
        }
    }
Ejemplo n.º 5
0
        public static IShop GetShop(ShopEnum shop)
        {
            switch (shop)
            {
            case ShopEnum.Maxima: return(new Maxima());

            case ShopEnum.Norfa: return(new Norfa());

            case ShopEnum.Rimi: return(new Rimi());

            case ShopEnum.Iki: return(new Iki());

            default: throw new ArgumentException(string.Format("No matching shop class ({0})", shop.ToString()));
            }
        }
Ejemplo n.º 6
0
    public int GetBoughtCount(ShopEnum type, int id)
    {
        UpdateShopDict();
        var data = shopDic[type];

        if (data.ContainsKey(id))
        {
            return(data[id]);
        }
        else
        {
            data.Add(id, 0);
            return(data[id]);
        }
    }
Ejemplo n.º 7
0
 private ShopProfile(
     ShopEnum shop, string account, string sellerId,
     string displayName, string displayNameOnBill, string shortName,
     string senderName, string senderPhone, string ad,
     string ordersDbFilename, string fullOrdersDbFilename)
 {
     _shop              = shop;
     _account           = account;
     _sellerId          = sellerId;
     _displayName       = displayName;
     _displayNameOnBill = displayNameOnBill;
     _shortName         = shortName;
     _senderName        = senderName;
     _senderPhone       = senderPhone;
     _ad = ad;
     _ordersDbFilename     = ordersDbFilename;
     _fullOrdersDbFilename = fullOrdersDbFilename;
 }
Ejemplo n.º 8
0
 public static Receipt Create(ShopEnum shop, List <Item> items, DateTime dateTime, int total)
 {
     return(new Receipt(shop, items, dateTime, total));
 }
Ejemplo n.º 9
0
 public static Receipt Create(ShopEnum shop, List <Item> items)
 {
     return(new Receipt(shop, items));
 }
Ejemplo n.º 10
0
 private Receipt(ShopEnum shop, List <Item> items, DateTime dateTime, int total) : this(shop, items, dateTime)
 {
     Total = total;
 }
Ejemplo n.º 11
0
 private Receipt(ShopEnum shop, List <Item> items, DateTime dateTime) : this(shop, items)
 {
     PurchaseTime = dateTime;
 }
Ejemplo n.º 12
0
 public Item(string name, int price, ShopEnum shop) : this()
 {
     Name = name;
     Prices[(int)shop] = price;
 }
Ejemplo n.º 13
0
 public bool IsAvailableForBuying(ShopEnum type, int idPack, int stock)
 {
     return(dataShop.IsAvailableForBuying(type, idPack, stock));
 }
Ejemplo n.º 14
0
    public int GetBoughtCount(ShopEnum type, int idPack)
    {
        return(dataShop.GetBoughtCount(type, idPack));

        ;
    }
Ejemplo n.º 15
0
 public void AddBought(ShopEnum type, int idPack)
 {
     dataShop.AddBought(type, idPack);
     Save();
 }