Example #1
0
        private void GetRomInfo()
        {
            Console.Write("ROM name: ");
            for (int i = 0; i < 16; i++)
            {
                char c = (char)rom[0x0134 + i];
                if (c == 0)
                {
                    break;
                }
                Console.Write(c);
            }

            Console.WriteLine();

            CartType cartType   = (CartType)rom[0x0147];
            string   typeString = cartType.ToString();

            Console.WriteLine($"ROM type: {typeString.ToUpper()} ({(int)cartType})");

            romSize = 0x20 << rom[0x0148];
            Console.WriteLine($"ROM size: {romSize}K ({romSize >> 4} banks)");

            hasRam  = typeString.Contains("Ram");
            ramSize = ramSizes[rom[0x0149]];

            if (ramSize == 0)
            {
                hasRam = false;
            }

            Console.WriteLine($"Has RAM: {(hasRam ? $"Yes\nRAM size: {ramSize}K" : "No")}");

            hasBattery = typeString.Contains("Battery");
            Console.WriteLine($"Has battery: {(hasBattery ? "Yes" : "No")}");

            switch (typeString)
            {
            case var type when type.Contains("Rom"):
                ReadByte = ReadByteRomOnly;

                WriteByte = WriteByteRomOnly;
                break;

            case var type when type.Contains("Mbc1"):
                ReadByte = ReadByteMbc1;

                WriteByte = WriteByteMbc1;
                break;

            case var type when type.Contains("Mbc3"):
                ReadByte = ReadByteMbc3;

                WriteByte = WriteByteMbc3;
                break;

            default:
                break;
            }
        }
        public override TypedEntity LoadTree(TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;

            if (ctree == null || base.LoadTree(tree) == null)
            {
                return(null);
            }

            _type = (CartType)ctree["Type"].ToTagInt().Data;

            switch (_type)
            {
            case CartType.EMPTY:
                return(this);

            case CartType.CHEST:
                return(new EntityMinecartChest().LoadTreeSafe(tree));

            case CartType.FURNACE:
                return(new EntityMinecartFurnace().LoadTreeSafe(tree));

            default:
                return(this);
            }
        }
Example #3
0
        /// <summary>
        /// Creates an instance of the specified cart.
        /// </summary>
        /// <param name="romBytes"></param>
        /// <param name="cartType"></param>
        /// <exception cref="Emu7800Exception">Specified CartType is unexpected.</exception>
        public static Cart Create(byte[] romBytes, CartType cartType)
        {
            if (cartType == CartType.Unknown)
            {
                switch (romBytes.Length)
                {
                case 2048:
                    cartType = CartType.A2K;
                    break;

                case 4096:
                    cartType = CartType.A4K;
                    break;

                case 8192:
                    cartType = CartType.A8K;
                    break;

                case 16384:
                    cartType = CartType.A16K;
                    break;

                case 32768:
                    cartType = CartType.A32K;
                    break;
                }
            }

            return(cartType switch
            {
                CartType.A2K => new CartA2K(romBytes),
                CartType.A4K => new CartA4K(romBytes),
                CartType.A8K => new CartA8K(romBytes),
                CartType.A8KR => new CartA8KR(romBytes),
                CartType.A16K => new CartA16K(romBytes),
                CartType.A16KR => new CartA16KR(romBytes),
                CartType.DC8K => new CartDC8K(romBytes),
                CartType.PB8K => new CartPB8K(romBytes),
                CartType.TV8K => new CartTV8K(romBytes),
                CartType.CBS12K => new CartCBS12K(romBytes),
                CartType.A32K => new CartA32K(romBytes),
                CartType.A32KR => new CartA32KR(romBytes),
                CartType.MN16K => new CartMN16K(romBytes),
                CartType.DPC => new CartDPC(romBytes),
                CartType.M32N12K => new CartA2K(romBytes, _multicartBankSelector++),
                CartType.A7808 => new Cart7808(romBytes),
                CartType.A7816 => new Cart7816(romBytes),
                CartType.A7832P => new Cart7832P(romBytes),
                CartType.A7832 => new Cart7832(romBytes),
                CartType.A7848 => new Cart7848(romBytes),
                CartType.A78SGP => new Cart78SGP(romBytes),
                CartType.A78SG => new Cart78SG(romBytes, false),
                CartType.A78SGR => new Cart78SG(romBytes, true),
                CartType.A78S9 => new Cart78S9(romBytes),
                CartType.A78S4 => new Cart78S4(romBytes, false),
                CartType.A78S4R => new Cart78S4(romBytes, true),
                CartType.A78AB => new Cart78AB(romBytes),
                CartType.A78AC => new Cart78AC(romBytes),
                _ => throw new Emu7800Exception("Unexpected CartType: " + cartType),
            });
 public Deposit(int id, string name, decimal balance, decimal bonusBalance, CartType cart)
 {
     this.Id           = id;
     this.Name         = name;
     this.Balance      = balance;
     this.CartType     = cart;
     this.BonusBalance = bonusBalance;
 }
Example #5
0
 public EntityMinecart (TypedEntity e)
     : base(e)
 {
     EntityMinecart e2 = e as EntityMinecart;
     if (e2 != null) {
         _type = e2._type;
     }
 }
Example #6
0
        /// <summary>
        /// Creates an instance of the specified cart.
        /// </summary>
        /// <param name="romBytes"></param>
        /// <param name="cartType"></param>
        /// <exception cref="Emu7800Exception">Specified CartType is unexpected.</exception>
        public static Cart Create(byte[] romBytes, CartType cartType)
        {
            if (cartType == CartType.None)
            {
                switch (romBytes.Length)
                {
                    case 2048:
                        cartType = CartType.A2K;
                        break;
                    case 4096:
                        cartType = CartType.A4K;
                        break;
                    case 8192:
                        cartType = CartType.A8K;
                        break;
                    case 16384:
                        cartType = CartType.A16K;
                        break;
                    case 32768:
                        cartType = CartType.A32K;
                        break;
                }
            }

            switch (cartType)
            {
                case CartType.A2K:     return new CartA2K(romBytes);
                case CartType.A4K:     return new CartA4K(romBytes);
                case CartType.A8K:     return new CartA8K(romBytes);
                case CartType.A8KR:    return new CartA8KR(romBytes);
                case CartType.A16K:    return new CartA16K(romBytes);
                case CartType.A16KR:   return new CartA16KR(romBytes);
                case CartType.DC8K:    return new CartDC8K(romBytes);
                case CartType.PB8K:    return new CartPB8K(romBytes);
                case CartType.TV8K:    return new CartTV8K(romBytes);
                case CartType.CBS12K:  return new CartCBS12K(romBytes);
                case CartType.A32K:    return new CartA32K(romBytes);
                case CartType.A32KR:   return new CartA32KR(romBytes);
                case CartType.MN16K:   return new CartMN16K(romBytes);
                case CartType.DPC:     return new CartDPC(romBytes);
                case CartType.M32N12K: return new CartA2K(romBytes, _multicartBankSelector++);
                case CartType.A7808:   return new Cart7808(romBytes);
                case CartType.A7816:   return new Cart7816(romBytes);
                case CartType.A7832P:  return new Cart7832P(romBytes);
                case CartType.A7832:   return new Cart7832(romBytes);
                case CartType.A7848:   return new Cart7848(romBytes);
                case CartType.A78SGP:  return new Cart78SGP(romBytes);
                case CartType.A78SG:   return new Cart78SG(romBytes, false);
                case CartType.A78SGR:  return new Cart78SG(romBytes, true);
                case CartType.A78S9:   return new Cart78S9(romBytes);
                case CartType.A78S4:   return new Cart78S4(romBytes, false);
                case CartType.A78S4R:  return new Cart78S4(romBytes, true);
                case CartType.A78AB:   return new Cart78AB(romBytes);
                case CartType.A78AC:   return new Cart78AC(romBytes);
                default:
                    throw new Emu7800Exception("Unexpected CartType: " + cartType);
            }
        }
        public EntityMinecart(TypedEntity e)
            : base(e)
        {
            EntityMinecart e2 = e as EntityMinecart;

            if (e2 != null)
            {
                _type = e2._type;
            }
        }
Example #8
0
        public Cart(string romName)
        {
            this.romName = romName;
            RAM          = new Memory(0xFFFF + 1);

            if (!File.Exists(romName))
            {
                throw new FileNotFoundException("Couldn't open up a Game Boy ROM.", romName);
            }

            ROM  = new Memory(File.ReadAllBytes(romName));
            Type = GetCartType();
            ROM.CopyInto(RAM);
        }
Example #9
0
        public static void Configure(CartType type)
        {
            switch (type)
            {
            case CartType.Session:
                _cartType = new SessionContainerRepository();
                break;

            case CartType.Cookie:
                _cartType = new CookieContainerRepository();
                break;

            default:
                _cartType = new SessionContainerRepository();
                break;
            }
        }
Example #10
0
        public override TypedEntity LoadTree (TagNode tree)
        {
            TagNodeCompound ctree = tree as TagNodeCompound;
            if (ctree == null || base.LoadTree(tree) == null) {
                return null;
            }

            _type = (CartType)ctree["Type"].ToTagInt().Data;

            switch (_type) {
                case CartType.EMPTY:
                    return this;
                case CartType.CHEST:
                    return new EntityMinecartChest().LoadTreeSafe(tree);
                case CartType.FURNACE:
                    return new EntityMinecartFurnace().LoadTreeSafe(tree);
                default:
                    return this;
            }
        }
Example #11
0
        private async Task <IActionResult> PrepareCartListView(CartType cartType)
        {
            var seller = await HttpContext.GetSellerAsync();

            var customer = await HttpContext.GetMemberAsync();

            var filter = new CartFilter {
                SellerId = seller.Id, CustomerId = customer.Id, Type = cartType
            };

            var carts = (await _cartService.ListAsync(filter));

            // Ensure all carts are validated before evaluation.
            carts = carts.Where(x => _cartService.Validate(x).Success);

            var model = new CartListModel
            {
                Filter   = filter,
                CartType = cartType
            };
            await _appService.PrepareModelAsync(model, carts.ToPageable());

            return(View("CartList", model));
        }
        private CartExtractor m_cart; //cart specific settings are stored in the cart extractor

        #endregion Fields

        #region Constructors

        public Client(XElement settings, bool createCart = true)
        {
            Alias = GetValue(settings, "alias");
            PocName = GetValue(settings, "pocName");
            PocEmail = GetValue(settings, "pocEmail");
            ReportLevel = GetValue(settings, "reportLevel");

            IEnumerable<XElement> ipList = settings.Elements("approvedUploadIP");
            if (ipList != null)
                UploadAddresses = ipList.Select(ip => ip.Value).ToList<string>();

            CartLevel = 0;
            m_cart = null;
            if (createCart)
            {
                try
                {
            #if DEBUG
                    string test = GetValue(settings, "cartType");
                    BoostLog.Instance.WriteEntry(string.Format("CartType for {0} is {1}", Alias, test),EventLogEntryType.Information, Alias);
            #endif
                    CartType = (CartType)Enum.Parse(typeof(CartType), GetValue(settings, "cartType"), true);
                    string level = GetValue(settings, "cartLevel");
                    switch (CartType)
                    {
                        case CartType.Magento:
                            MagentoLevel mLevel = (MagentoLevel)Enum.Parse(typeof(MagentoLevel), level, true);
                            CartLevel = (int)mLevel;
                            if (mLevel == MagentoLevel.Go)
                                m_cart = (CartExtractor)new MagentoExtractor(Alias, settings);
                            break;
                        case CartType.ThreeDCart:
                            ThreeDCartLevel tLevel = (ThreeDCartLevel)Enum.Parse(typeof(ThreeDCartLevel), level, true);
                            CartLevel = (int)tLevel;
                            m_cart = (CartExtractor)new ThreeDCartExtractor(Alias, settings);
                            break;
                        case CartType.Volusion:
                            CartLevel = 0;
                            m_cart = (CartExtractor)new VolusionExtractor(Alias, settings);
                            break;
                        case CartType.MivaMerchant:
                            CartLevel = 0;
                            m_cart = (CartExtractor)new MivaMerchantExtractor(Alias, settings);
                            break;
                        case CartType.BigCommerce:
                            CartLevel = 0;
                            m_cart = (CartExtractor)new BigCommerceExtractor(Alias, settings);
                            break;
                        default:
                            if (level.Length > 0)
                                CartLevel = Convert.ToInt32(level); //default is just a numeric level
                            break;
                    }
                }
                catch
                {
                    CartType = CartType.other;
                    m_cart = null;
                    CartLevel = 0;
                }
            }
        }
Example #13
0
        /// <summary>
        /// Creates an instance of the specified cart.
        /// </summary>
        /// <param name="romBytes"></param>
        /// <param name="cartType"></param>
        /// <exception cref="Emu7800Exception">Specified CartType is unexpected.</exception>
        public static Cart Create(byte[] romBytes, CartType cartType)
        {
            if (cartType == CartType.None)
            {
                switch (romBytes.Length)
                {
                case 2048:
                    cartType = CartType.A2K;
                    break;

                case 4096:
                    cartType = CartType.A4K;
                    break;

                case 8192:
                    cartType = CartType.A8K;
                    break;

                case 16384:
                    cartType = CartType.A16K;
                    break;

                case 32768:
                    cartType = CartType.A32K;
                    break;
                }
            }

            switch (cartType)
            {
            case CartType.A2K:     return(new CartA2K(romBytes));

            case CartType.A4K:     return(new CartA4K(romBytes));

            case CartType.A8K:     return(new CartA8K(romBytes));

            case CartType.A8KR:    return(new CartA8KR(romBytes));

            case CartType.A16K:    return(new CartA16K(romBytes));

            case CartType.A16KR:   return(new CartA16KR(romBytes));

            case CartType.DC8K:    return(new CartDC8K(romBytes));

            case CartType.PB8K:    return(new CartPB8K(romBytes));

            case CartType.TV8K:    return(new CartTV8K(romBytes));

            case CartType.CBS12K:  return(new CartCBS12K(romBytes));

            case CartType.A32K:    return(new CartA32K(romBytes));

            case CartType.A32KR:   return(new CartA32KR(romBytes));

            case CartType.MN16K:   return(new CartMN16K(romBytes));

            case CartType.DPC:     return(new CartDPC(romBytes));

            case CartType.M32N12K: return(new CartA2K(romBytes, _multicartBankSelector++));

            case CartType.A7808:   return(new Cart7808(romBytes));

            case CartType.A7816:   return(new Cart7816(romBytes));

            case CartType.A7832P:  return(new Cart7832P(romBytes));

            case CartType.A7832:   return(new Cart7832(romBytes));

            case CartType.A7848:   return(new Cart7848(romBytes));

            case CartType.A78SGP:  return(new Cart78SGP(romBytes));

            case CartType.A78SG:   return(new Cart78SG(romBytes, false));

            case CartType.A78SGR:  return(new Cart78SG(romBytes, true));

            case CartType.A78S9:   return(new Cart78S9(romBytes));

            case CartType.A78S4:   return(new Cart78S4(romBytes, false));

            case CartType.A78S4R:  return(new Cart78S4(romBytes, true));

            case CartType.A78AB:   return(new Cart78AB(romBytes));

            case CartType.A78AC:   return(new Cart78AC(romBytes));

            default:
                throw new Emu7800Exception("Unexpected CartType: " + cartType);
            }
        }
        public XElement ReadCartRules(CartType cartType)
        {
            //TODO: define rules to read files uploaded from osCommerce
            if (cartType.Equals(CartType.osCommerce) || cartType.Equals(CartType.Other))
                return null;

            XElement cartRules;
            lock (_cartRules)
            {
                if (!_cartRules.TryGetValue(cartType, out cartRules))
                {
                    var path = "";
                    try
                    {
                        path = DataPath.Instance.Root + cartType.ToString() + "Rules.xml";
                        cartRules = XElement.Load(path);
                        if (!cartRules.IsEmpty)
                            _cartRules.Add(cartType, cartRules);
                    }
                    catch (Exception ex)
                    {
                        if (BoostLog.Instance != null)
                            BoostLog.Instance.WriteEntry(EventLogEntryType.Error, "Error reading CartRules from " + path, ex, "");
                    }
                }
            }
            return cartRules;
        }
Example #15
0
        private MemoryBankController CreateMBC(CartType cartType, Stream fileStream)
        {
            MemoryBankController mbc = null;

            switch (cartType)
            {
                case CartType.RomOnly:
                    mbc = new RomOnly(fileStream);
                    break;
                case CartType.MBC1:
                    mbc = new Mbc1(fileStream);
                    break;
                case CartType.MBC2:
                    mbc = new Mbc2(fileStream);
                    break;
            }

            return mbc;
        }
Example #16
0
        static Cart New(BinaryReader rom, CartType cartType)
        {
            Cart c;

            switch (cartType)
            {
                case CartType.A2K:
                    c = new CartA2K(rom);
                    break;
                case CartType.A4K:
                    c = new CartA4K(rom);
                    break;
                case CartType.A8K:
                    c = new CartA8K(rom);
                    break;
                case CartType.A8KR:
                    c = new CartA8KR(rom);
                    break;
                case CartType.A16K:
                    c = new CartA16K(rom);
                    break;
                case CartType.A16KR:
                    c = new CartA16KR(rom);
                    break;
                case CartType.DC8K:
                    c = new CartDC8K(rom);
                    break;
                case CartType.PB8K:
                    c = new CartPB8K(rom);
                    break;
                case CartType.TV8K:
                    c = new CartTV8K(rom);
                    break;
                case CartType.CBS12K:
                    c = new CartCBS12K(rom);
                    break;
                case CartType.A32K:
                    c = new CartA32K(rom);
                    break;
                case CartType.A32KR:
                    c = new CartA32KR(rom);
                    break;
                case CartType.MN16K:
                    c = new CartMN16K(rom);
                    break;
                case CartType.DPC:
                    c = new CartDPC(rom);
                    break;
                case CartType.A7808:
                    c = new Cart7808(rom);
                    break;
                case CartType.A7816:
                    c = new Cart7816(rom);
                    break;
                case CartType.A7832P:
                case CartType.A7832:
                    c = new Cart7832(rom);
                    break;
                case CartType.A7848:
                    c = new Cart7848(rom);
                    break;
                case CartType.A78SGP:
                case CartType.A78SG:
                    c = new Cart78SG(rom, false);
                    break;
                case CartType.A78SGR:
                    c = new Cart78SG(rom, true);
                    break;
                case CartType.A78S9:
                    c = new Cart78S9(rom);
                    break;
                case CartType.A78S4:
                    c = new Cart78S4(rom, false);
                    break;
                case CartType.A78S4R:
                    c = new Cart78S4(rom, true);
                    break;
                case CartType.A78AB:
                    c = new Cart78AB(rom);
                    break;
                case CartType.A78AC:
                    c = new Cart78AC(rom);
                    break;
                default:
                    throw new Exception("Unexpected CartType: " + cartType.ToString());
            }
            return c;
        }
        /// <summary>
        /// Creates a newset of SiteRules using the default settings for the given cart type
        /// </summary>
        /// <param name="alias"></param>
        /// <param name="url"></param>
        /// <param name="tier"></param>
        /// <param name="cart"></param>
        /// <param name="key"></param>
        public SiteRules(string alias, string url, BoostTier tier, CartType cart, string key, bool saveRules = true)
        {
            Alias = alias;
            StoreShortUrl = CleanUpUrl(url);
            Tier = tier;
            CartType = cart;
            ApiKey = key; //auto-calculated key is removed for certain platforms in SetCartDefaults

            InitializeStructures();
            SetDefaultValues();
            SetCartDefaults();
            if (saveRules)
                QueueSettings();
        }
        /// <summary>
        /// Return the rules related to the cart, telling what type of extraction and upload options are valid
        /// These are general rules related to the cart type, not specific to the client.
        /// </summary>
        /// <returns>DashCartDefinition</returns>
        public static DashCartDefinition GetCartRules(CartType cartType)
        {
            //note, this is defined here instead of using an abstract method
            //so that cart rules can exist for cart types that don't have extractors

            var rules = new DashCartDefinition{ CartId = (int)cartType, CartValue = cartType.ToString() };
            switch (cartType)
            {
                case CartType.BigCommerce:
                    rules.CartDisplayName = "BigCommerce";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.CommerceV3:
                    rules.CartDisplayName = "Commerce V3";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.MivaMerchant:
                    rules.CartDisplayName = "MivaMerchant";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.ThreeDCart:
                    rules.CartDisplayName = "3dcart";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.Volusion:
                    rules.CartDisplayName = "Volusion";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.Shopify:
                    rules.CartDisplayName = "Shopify";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.NetSuite:
                    rules.CartDisplayName = "NetSuite";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.JsonFeed:
                    rules.CartDisplayName = "JsonFeed";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.XmlFeed:
                    rules.CartDisplayName = "XmlFeed";
                    rules.HasCartExtractor = true;
                    rules.CanExtractCatalog = true;
                    rules.CanExtractAllSales = true;
                    rules.CanExtractSalesUpdate = true;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
                case CartType.TabbedFeed:
                case CartType.osCommerce:
                case CartType.Magento:
                case CartType.PrestaShop:
                case CartType.WebsitePipeline:
                case CartType.Other:
                default:
                    rules.CartDisplayName = cartType.ToString();
                    rules.HasCartExtractor = false;
                    rules.CanExtractCatalog = false;
                    rules.CanExtractAllSales = false;
                    rules.CanExtractSalesUpdate = false;
                    rules.HasManualUpload = true;
                    rules.HasManualUploadLink = false;
                    break;
            }
            return rules;
        }
Example #19
0
		public static extern bool libyabause_init(ref CDInterface intf, string biosfn, bool usegl, CartType carttype, bool quickload, bool clocksync, int clockbase);
Example #20
0
 public static extern bool libyabause_init(ref CDInterface intf, string biosfn, bool usegl, CartType carttype, bool quickload, bool clocksync, int clockbase);
Example #21
0
        private bool SaveCart(SessionCart tempCart, CartSummary summary, int userId, string transactionId, CartType cartType)
        {
            try
            {
                Cart cart = new Cart
                {
                    TransactionDate = DateTime.Now,
                    TransactionId = transactionId,
                    UserId = userId,
                    CartType = cartType,
                    CartItems = new List<CartItem>(),
                    TotalCost = summary.TotalCost
                };

                _repository.Carts.Create(cart);
                _repository.SaveChanges();

                foreach (var summaryItem in summary.CartItems)
                {
                    CartItem newItem = new CartItem
                        {
                            CartId = cart.CartId,
                            PurchaseItemId = summaryItem.PurchaseItemId,
                            Cost = summaryItem.ItemCost,
                            Total = summaryItem.ItemTotal,
                            StandAloneItem = summaryItem.ProcessType == ProcessType.Individual ? true : false,
                            LocalTaxPercentage = summaryItem.LocalTaxPercentage,
                            LocalTaxValue = summaryItem.LocalTax,
                            StateTaxPercentage = summaryItem.StateTaxPercentage,
                            StateTaxValue = summaryItem.StateTax,
                            DiscountItemId = summaryItem.DiscountItemId,
                            DiscountValue = summaryItem.DiscountValue,
                            DiscountType = summaryItem.DiscountType,
                            DiscountValueTotal = summaryItem.DiscountTotal
                        };

                    cart.CartItems.Add(newItem);

                    _repository.SaveChanges();

                    if (summaryItem.SessionKey.HasValue && tempCart.ActionItems[summaryItem.SessionKey.Value].ActionObject != null)
                    {
                        ActionItem action = tempCart.ActionItems[summaryItem.SessionKey.Value];
                        int? discountId = summaryItem.DiscountItemId;
                        CompleteActions(action, newItem.CartItemId, discountId, transactionId);
                    }

                }

                IEmailService emailService = new EmailService();
                emailService.SendPaymentConfirmationEmail(cart.CartId);

                tempCart.ResultingConfirmationCode = cart.TransactionId;

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Example #22
0
        private bool SaveCart(SessionCart tempCart, CartSummary summary, int userId, string transactionId, CartType cartType)
        {
            try
            {
                Cart cart = new Cart
                {
                    TransactionDate = DateTime.Now,
                    TransactionId   = transactionId,
                    UserId          = userId,
                    CartType        = cartType,
                    CartItems       = new List <CartItem>(),
                    TotalCost       = summary.TotalCost
                };

                _repository.Carts.Create(cart);
                _repository.SaveChanges();

                foreach (var summaryItem in summary.CartItems)
                {
                    CartItem newItem = new CartItem
                    {
                        CartId             = cart.CartId,
                        PurchaseItemId     = summaryItem.PurchaseItemId,
                        Cost               = summaryItem.ItemCost,
                        Total              = summaryItem.ItemTotal,
                        StandAloneItem     = summaryItem.ProcessType == ProcessType.Individual ? true : false,
                        LocalTaxPercentage = summaryItem.LocalTaxPercentage,
                        LocalTaxValue      = summaryItem.LocalTax,
                        StateTaxPercentage = summaryItem.StateTaxPercentage,
                        StateTaxValue      = summaryItem.StateTax,
                        DiscountItemId     = summaryItem.DiscountItemId,
                        DiscountValue      = summaryItem.DiscountValue,
                        DiscountType       = summaryItem.DiscountType,
                        DiscountValueTotal = summaryItem.DiscountTotal
                    };

                    cart.CartItems.Add(newItem);

                    _repository.SaveChanges();

                    if (summaryItem.SessionKey.HasValue && tempCart.ActionItems[summaryItem.SessionKey.Value].ActionObject != null)
                    {
                        ActionItem action     = tempCart.ActionItems[summaryItem.SessionKey.Value];
                        int?       discountId = summaryItem.DiscountItemId;
                        CompleteActions(action, newItem.CartItemId, discountId, transactionId);
                    }
                }

                IEmailService emailService = new EmailService();
                emailService.SendPaymentConfirmationEmail(cart.CartId);

                tempCart.ResultingConfirmationCode = cart.TransactionId;

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 public ArrayList GetAliasList(CartType cart)
 {
     var aliasList = new ArrayList();
     foreach (Client c in m_clients)
     {
         if (c.CartType == cart)
             aliasList.Add(c.Alias);
     }
     return aliasList;
 }
Example #24
0
 public static string ToCartTypeWordString(CartType cartType)
 => cartType switch
 {
Example #25
0
    void UpdateCart(int id, RepeaterItem item, CartType mode)
    {
        dsCart.CartRow drCart = da.Cart_GetDataByID(id);
        if (drCart != null)
        {
            #region Optional Items
            // Only applicable to machine
            if (mode == CartType.Machine)
            {
                Repeater repOptional = (Repeater)item.FindControl("repOptional");
                foreach (RepeaterItem itemOptional in repOptional.Items)
                {
                    HiddenField hidOptionalItemID = (HiddenField)itemOptional.FindControl("hidOptionalItemID");

                    TextBox txtOptionalQuantity = (TextBox)itemOptional.FindControl("txtOptionalQuantity");

                    dsCartOptionalItem.CartOptionalItemRow cartOptionalRow = da.CartOptionalItem_Get(int.Parse(hidOptionalItemID.Value));
                    if (Common.IsNum(txtOptionalQuantity.Text) && int.Parse(txtOptionalQuantity.Text) <= 9999)
                        cartOptionalRow.Quantity = int.Parse(txtOptionalQuantity.Text);
                    else
                        cartOptionalRow.Quantity = 1;

                    // Remove Item
                    if (cartOptionalRow.Quantity == 0)
                        cartOptionalRow.Delete();

                    da.CartOptionalItem_Update(cartOptionalRow);
                }
            }
            #endregion

            TextBox txtQuantity = (TextBox)item.FindControl("txtQuantity");
            if (Common.IsNum(txtQuantity.Text) && int.Parse(txtQuantity.Text) <= 9999)
                drCart.Quantity = int.Parse(txtQuantity.Text);
            else
                drCart.Quantity = 1;
            
            // Remove Item
            if (drCart.Quantity == 0)
                drCart.Delete();

            da.Cart_Update(drCart);

            MasterBase.Message = WebLib.UpdatedSuccessfullyMessage;
        }
    }