/// <summary>
    /// Initializes a new instance of the <see cref="ItemBasedOrderIDGenerator" /> class.
    /// </summary>
    /// <param name="shopContext">The shop context.</param>
    /// <param name="generationStrategy">The generation strategy.</param>
    public ItemBasedOrderIDGenerator(ShopContext shopContext, OrderIDGenerationStrategy generationStrategy)
    {
      Assert.IsNotNull(shopContext, "Unable to generate order id. ShopContext cannot be null.");
      Assert.IsNotNull(generationStrategy, "Unable to generate order id. Order id generation strategy cannot be null.");

      this.shopContext = shopContext;
      this.generationStrategy = generationStrategy;
    }
    /// <summary>
    /// Initializes a new instance of the <see cref="StiReportConfirmationBuilder" /> class.
    /// </summary>
    /// <param name="reportFactory">The report factory.</param>
    /// <param name="reportModel">The report model.</param>
    /// <param name="shopContext">The shop context.</param>
    public StiReportConfirmationBuilder([NotNull] StiReportFactory reportFactory, OrderReportModel reportModel, ShopContext shopContext)
    {
      Assert.ArgumentNotNull(reportFactory, "reportFactory");
      Assert.ArgumentNotNull(reportModel, "reportModel");

      this.reportFactory = reportFactory;
      this.reportModel = reportModel;
      this.shopContext = shopContext;
    }
    /// <summary>
    /// Initializes a new instance of the <see cref="DefaultOrderFactory"/> class.
    /// </summary>
    /// <param name="idGenerator">The id generator.</param>
    /// <param name="shopContext">The shop context.</param>
    /// <param name="stateConfiguration">The state configuration.</param>
    /// <param name="currencyProvider">The currency provider.</param>
    public DefaultOrderFactory([NotNull] OrderIDGenerator idGenerator, [NotNull] ShopContext shopContext, [NotNull] CoreOrderStateConfiguration stateConfiguration, [NotNull] IEntityProvider<Currency> currencyProvider)
    {
      Assert.ArgumentNotNull(idGenerator, "idGenerator");
      Assert.ArgumentNotNull(shopContext, "shopContext");
      Assert.ArgumentNotNull(stateConfiguration, "stateConfiguration");
      Assert.ArgumentNotNull(currencyProvider, "currencyProvider");

      this.idGenerator = idGenerator;
      this.shopContext = shopContext;
      this.stateConfiguration = stateConfiguration;
      this.currencyProvider = currencyProvider;
    }
Exemplo n.º 4
0
        public OrderAndGoods GetOrder(int id)
        {
            using (var db = new ShopContext())
            {
                var orderAndGoods = new OrderAndGoods();
                var order = (from entity in db.Orders
                             where entity.Id == id
                             select entity).FirstOrDefault();
                orderAndGoods.Order = order;
                var goods = (from entity in db.Carts
                             where entity.OrderId == id
                             select entity).ToList();

                orderAndGoods.GoodsList = goods;
                return orderAndGoods;
            }
        }
        public virtual ShopContext GetShopContext([NotNull] SiteContext siteContext)
        {
            Assert.ArgumentNotNull(siteContext, "siteContext");

              if (siteContext.Properties["EcommerceSiteSettings"] == null)
              {
            return null;
              }

              BusinessCatalogSettings businessSettings = Context.Entity.GetConfiguration<BusinessCatalogSettings>();
              GeneralSettings generalSettings = Context.Entity.GetConfiguration<GeneralSettings>();

              ShopContext shopContext = new ShopContext(siteContext)
              {
            BusinessCatalogSettings = businessSettings,
            GeneralSettings = generalSettings,
            Database = siteContext.Database
              };

              return shopContext;
        }
Exemplo n.º 6
0
        public void AddOrder(Order order, List<Cart> listGoods)
        {
            using (var db = new ShopContext())
            {
                db.Orders.Add(order);
                db.SaveChanges();

                var email = order.Email;
                const string subject = "Your Order Id";

                var text = "Your Order Id:" + Environment.NewLine + order.Id;
                MailSender.sendMail(subject, email, text);

                foreach (var item in listGoods)
                {
                    item.OrderId = order.Id;
                    db.Carts.Add(item);
                }
                db.SaveChanges();

            }
        }
Exemplo n.º 7
0
        public List<SearchModel> GetAll(string modelName)
        {
            using (var db = new ShopContext())
            {
                //var batteries = (from entity in db.Batteries
                //                 where entity.Model.Contains(modelName)
                //                 select entity).ToList();
                //var monitors = (from entity in db.Monitors
                //                where entity.Model.Contains(modelName)
                //                select entity).ToList();

                //var list = batteries.Select(item => new SearchModel
                //{
                //    GoodsCategory = "Batteries", GoodsId = item.Id, Price = item.Price, Model = item.Model, Producer = item.Producer
                //}).ToList();
                //list.AddRange(monitors.Select(item => new SearchModel
                //{
                //    GoodsCategory = "Monitors", GoodsId = item.Id, Price = item.Price, Model = item.Model, Producer = item.Producer
                //}));

                return null;
            }
        }
Exemplo n.º 8
0
 public List<Order> GetOrders()
 {
     using (var db = new ShopContext())
     {
         var orders = (from entity in db.Orders
                       select entity).ToList();
         return orders;
     }
 }
 public UserRepository(ShopContext shopDatabase, ILogger <UserRepository> logger)
 {
     _shopDatabase = shopDatabase;
     _logger       = logger;
 }
Exemplo n.º 10
0
 public BasketController()
 {
     db             = new ShopContext();
     sessionManager = new SessionManager();
     basketManager  = new BasketManager(sessionManager, db);
 }
Exemplo n.º 11
0
 public GenericRepository(ShopContext context)
 {
     this.context = context;
     dbSet        = context.Set <T>();
 }
Exemplo n.º 12
0
 public ShopProductRepository(ShopContext context)
 {
     this.context = context;
 }
Exemplo n.º 13
0
 public Create(ShopContext shopContext)
 {
     _shopContext = shopContext;
 }
Exemplo n.º 14
0
        private static void DocumentationTest()
        {
            ShopContextFactory shopContextFactory = new ShopContextFactory();
            ShopContext        context            = shopContextFactory.Create();

            var metadata = context.ObjectContext.MetadataWorkspace;

            // Storage
            Console.WriteLine("######## Storage ########");
            var items = metadata.GetItems <EntityType>(DataSpace.SSpace);

            foreach (var item in items)
            {
                Console.WriteLine("----------------------------");
                Console.WriteLine($"Table name {item.Name}");
                Console.WriteLine("----------------------------");

                Console.WriteLine("Keys");

                foreach (var key in item.KeyMembers)
                {
                    Console.WriteLine($"{key.Name} {key.TypeUsage.EdmType.FullName}");
                }

                Console.WriteLine("Properties");
                foreach (var property in item.Properties)
                {
                    Console.WriteLine($"{property.Name} {property.TypeUsage.EdmType.FullName}");
                }
            }

            // Conceptual
            Console.WriteLine("######## Conceptual ########");
            var entities = metadata.GetItems <EntityType>(DataSpace.CSpace);

            foreach (var entity in entities)
            {
                Console.WriteLine("----------------------------");
                Console.WriteLine($"Entity name {entity.Name}");
                Console.WriteLine("----------------------------");

                Console.WriteLine("Keys");

                foreach (var key in entity.KeyMembers)
                {
                    Console.WriteLine($"{key.Name} {key.TypeUsage.EdmType.FullName}");
                }

                Console.WriteLine("Properties");
                foreach (var property in entity.Properties)
                {
                    Console.WriteLine($"{property.Name} {property.TypeUsage.EdmType.FullName}");
                }

                Console.WriteLine("Navigation Properties");
                foreach (var property in entity.NavigationProperties)
                {
                    Console.WriteLine($"{property.Name} {property.TypeUsage.EdmType.FullName}");
                }
            }
        }
Exemplo n.º 15
0
 public Handler(ShopContext context) => this.context = context;
Exemplo n.º 16
0
 public SearchService(ShopContext context)
 {
     this.context = context;
 }
Exemplo n.º 17
0
 public MomoService(ShopContext context, IConfiguration configuration)
 {
     _context       = context;
     _configuration = configuration;
 }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            IFormatter form = new CustomFormatter();

            FileStream fs = new FileStream("tekst.txt", FileMode.Create);

            var logger   = new FileLogger("FileLogger.txt");
            var context  = new ShopContext();
            var inserter = new ConstantDataInserter();

            inserter.InitializeContextWithData(context);
            var repo    = new ShopRepository(context, logger);
            var service = new ShopService(repo, logger);

            var owner = new Owner()
            {
                Name = "TurTur"
            };
            var car1 = new Car()
            {
                Owner = owner,
                Model = "Niezly",
                Year  = 1234
            };
            var car2 = new Car()
            {
                Owner = owner,
                Model = "gorszy",
                Year  = 0022
            };
            var list = new List <Car>
            {
                car1,
                car2
            };
            var driver = new Driver()
            {
                Cars = new Car[] { car1, car2 }
            };

            var prod = new ProductState(new Product("213"), 12, (decimal)14.32, new Percentage(12));

            Produktieren products = new Produktieren();

            products.states.Add(prod);

            ShopContextWrapper wrapper = new ShopContextWrapper(context);

            form.Serialize(fs, wrapper);

            FileStream deserFS      = new FileStream("tekst.txt", FileMode.Open);
            var        deser        = form.Deserialize(deserFS);
            var        deserContext = ((ShopContextWrapper)deser).GetContext();
            var        client       = deserContext.Invoices.First().Client;

            foreach (var cl in deserContext.Clients)
            {
                if (client == cl)
                {
                    cl.FirstName = "fafafaf";
                    Console.WriteLine("Szach mat!!!");
                }
            }
        }
Exemplo n.º 19
0
 public AdditionsRepository()
 {
     _context = new ShopContext();
 }
Exemplo n.º 20
0
 public ProductCategoryQuery(ShopContext shopContext, InventoryContext inventoryContext, DiscountContext discountContext)
 {
     _shopContext      = shopContext;
     _inventoryContext = inventoryContext;
     _discountContext  = discountContext;
 }
Exemplo n.º 21
0
 public ProductRepository(ShopContext context)
 {
     db = context;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Checks if current site context by home path.
 /// </summary>
 /// <param name="shopContext">The shop context.</param>
 /// <param name="itemId">The item identifier.</param>
 /// <returns>True if current shop context, otherwise false.</returns>
 private bool CheckIfCurrentSiteContextByHomePath(ShopContext shopContext, ID itemId)
 {
     return this.CheckIfItemIsDescendantOfSiteContextRoot(shopContext, itemId, shopContext.InnerSite.RootPath + shopContext.InnerSite.StartItem);
 }
Exemplo n.º 23
0
        private void HandleContextChange(ShopContext shopContext)
        {
            //Debug.Log("CONTEXT UI SHOP: " + shopContext);
            switch (shopContext)
            {
            case ShopContext.Purchase:
                scene.HideBackButton();
                showPurchasePanelAlwaysAvailableTween.PlayForward();
                showShopPanelTween.PlayForward();
                showDragPanelTween.PlayBackwards();
                showConfirmationPanelTween.PlayBackwards();
                break;

            case ShopContext.NewPlacement:
                scene.HideBackButton();
                showPurchasePanelAlwaysAvailableTween.PlayBackwards();
                showShopPanelTween.PlayBackwards();
                showDragPanelTween.PlayBackwards();
                showConfirmationPanelTween.PlayBackwards();
                break;

            case ShopContext.MovingPlacement:
                scene.HideBackButton();
                showPurchasePanelAlwaysAvailableTween.PlayBackwards();
                showShopPanelTween.PlayBackwards();
                if (!AnturaSpaceScene.I.TutorialMode)
                {
                    showDragPanelTween.PlayForward();
                }
                showConfirmationPanelTween.PlayBackwards();
                break;

            case ShopContext.SpecialAction:
                scene.HideBackButton();
                showShopPanelTween.PlayBackwards();
                showDragPanelTween.PlayBackwards();
                showConfirmationPanelTween.PlayBackwards();
                break;

            case ShopContext.Closed:
                if (!scene.TutorialMode)
                {
                    scene.ShowBackButton();
                }
                showPurchasePanelAlwaysAvailableTween.PlayForward();
                showConfirmationPanelTween.PlayBackwards();
                break;

            case ShopContext.Customization:
                scene.HideBackButton();
                showPurchasePanelAlwaysAvailableTween.PlayBackwards();
                showConfirmationPanelTween.PlayBackwards();
                break;

            case ShopContext.Hidden:
                if (!scene.TutorialMode)
                {
                    scene.ShowBackButton();
                }
                showPurchasePanelAlwaysAvailableTween.PlayBackwards();
                showConfirmationPanelTween.PlayBackwards();
                break;

            default:
                throw new ArgumentOutOfRangeException("shopContext", shopContext, null);
            }
        }
Exemplo n.º 24
0
 public CartItemsController(ShopContext context)
 {
     _context = context;
 }
 public ShopContextRepository(ShopContext context)
 {
     _context = context;
 }
Exemplo n.º 26
0
 public ProductsController(ShopContext context)
 {
     db = context;
 }
Exemplo n.º 27
0
 public SchemaFactory(ShopContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 28
0
 public ProductService(ShopContext context)
 {
     _context = context;
 }
Exemplo n.º 29
0
 public CategoriesController(ShopContext context)
 {
     _context = context;
 }
Exemplo n.º 30
0
 public ProductRepository()
 {
     _shopContext = new ShopContext();
 }
 public ProductRepository(ShopContext context) : base(context)
 {
     _context = context;
 }
Exemplo n.º 32
0
 public CategoryRepository(ShopContext shopContext) : base(shopContext)
 {
 }
 public ShopApiController()
 {
   _ctx = new Models.ShopContext();
 }
Exemplo n.º 34
0
 public GenericRepository(ShopContext context)
 {
     this.shopContext = context;
     this.dbSet = context.Set<TEntity>();
 }
Exemplo n.º 35
0
 public GoodsRepository(ShopContext context) : base(context, context.Goods)
 {
 }
Exemplo n.º 36
0
 public UsersRepository(ShopContext dbContext) : base(dbContext)
 {
 }
Exemplo n.º 37
0
 void Awake()
 {
     Context = new ShopContext();
     View.SetContext(Context);
 }
Exemplo n.º 38
0
 public BasketController(ShopContext context)
 {
     db = context;
 }
Exemplo n.º 39
0
        static void Main(string[] args)
        {
            using (var db = new ShopContext())
            {
                var monitor = new Commodity();
                var battery = new Commodity();

                monitor.Model = "y570";
                monitor.Price = 2120;
                monitor.Producer = "Lenovo";
                monitor.Category = "Monitors";

                //battery.Model = "sl10";
                //battery.Price = 20;
                //battery.Producer = "lenovo";
                //battery.Category = "Batteries";

                db.DbGoods.Add(monitor);
                //db.DbGoods.Add(battery);

                var prop = new Property
                {
                    Name = "ScreenSize",
                    ValueChar = "1920x1080",
                };
                var prop2 = new Property
                {
                    Name = "Resolution",
                    ValueChar = "1920x1080",
                };

                //Person john = new Person();
                //john.FirstName = "John";
                //john.LastName = "Paul";
                prop.Goods.Add(monitor);
                prop2.Goods.Add(monitor);
                //prop.Goods.Add(battery);

                db.DbProperties.Add(prop);
                db.DbProperties.Add(prop2);
                db.SaveChanges();
                var goods = db.DbGoods.Include(p => p.Properties).ToList();
                Console.Write(goods.ToString());
                Console.ReadKey();
            }
        }
Exemplo n.º 40
0
 public BicyclesController(ShopContext context)
 {
     _context = context;
 }
Exemplo n.º 41
0
 public MemoryController(ShopContext context)
 {
     _context = context;
 }
Exemplo n.º 42
0
 public ShopRepository(ShopContext shopDatabase, ILogger <ShopRepository> logger)
 {
     _logger       = logger;
     _shopDatabase = shopDatabase;
 }
Exemplo n.º 43
0
        /// <summary>
        /// Checks if current shop context.
        /// </summary>
        /// <param name="shopContext">The shop context.</param>
        /// <param name="database">The database.</param>
        /// <param name="itemId">The item identifier.</param>
        /// <returns>True if current shop context, otherwise false.</returns>
        private bool CheckIfCurrentShopContext(ShopContext shopContext, Database database, ID itemId)
        {
            if (database != null)
              {
            shopContext.Database = database;
              }

              return this.CheckIfCurrentSiteContextByHomePath(shopContext, itemId)
            || this.CheckIfCurrentSiteContextByContentPath(shopContext, itemId);
        }
Exemplo n.º 44
0
 public ProductController(ShopContext ctx)
 {
     context = ctx;
 }
Exemplo n.º 45
0
        /// <summary>
        /// Checks if item is descendant of site context root.
        /// </summary>
        /// <param name="shopContext">The shop context.</param>
        /// <param name="itemId">The item identifier.</param>
        /// <param name="rootPath">The root path.</param>
        /// <returns>True if current shop context, otherwise false.</returns>
        private bool CheckIfItemIsDescendantOfSiteContextRoot(ShopContext shopContext, ID itemId, string rootPath)
        {
            if (shopContext.Database == null)
              {
            return false;
              }

              var item = shopContext.Database.GetItem(itemId);
              var rootItem = shopContext.Database.GetItem(rootPath);
              return item != null && rootItem != null && (rootItem.Axes.IsAncestorOf(item) || rootItem.ID == itemId);
        }
        /// <summary>
        /// Runs the processor.
        /// </summary>
        /// <param name="args">The args.</param>
        public virtual void Process([NotNull] PipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

              SiteContext contextSite = Sitecore.Context.Site;
              if (contextSite == null || string.Compare(this.MerchantSiteName, Sitecore.Context.Site.Name, StringComparison.OrdinalIgnoreCase) != 0)
              {
            return;
              }

              string storedSiteName = Sitecore.Context.User.Profile.GetSelectedShopContext();

              SiteContext site = null;
              if (!string.IsNullOrEmpty(storedSiteName))
              {
            site = this.SiteContextFactory.GetSiteContext(storedSiteName);
              }

              if (site == null && !string.IsNullOrEmpty(this.ShopContextName))
              {
            site = this.SiteContextFactory.GetSiteContext(this.ShopContextName);
            if (site != null)
            {
              Sitecore.Context.User.Profile.SetDefaultShopContext(this.ShopContextName);
              Sitecore.Context.User.Profile.Save();
            }
              }

              if (string.IsNullOrEmpty(this.ShopContextName))
              {
            Sitecore.Context.User.Profile.SetDefaultShopContext(string.Empty);
            Sitecore.Context.User.Profile.Save();
              }

              if (site != null)
              {
            var database = site.ContentDatabase;
            ShopContext shop = new ShopContext(site)
            {
              Database = database,
              BusinessCatalogSettings = this.ShopConfiguration.GetBusinesCatalogSettings(site, database),
              GeneralSettings = this.ShopConfiguration.GetGeneralSettings(site, database)
            };

            Context.Entity.RegisterInstance(typeof(ShopContext), null, shop, new HierarchicalLifetimeManager());
              }
              else
              {
            Context.Entity.RegisterInstance(typeof(LoggingProvider), null, new EmptyLoggingProvider(), new HierarchicalLifetimeManager());
            Context.Entity.RegisterInstance(typeof(Data.Repository<Order>), null, new EmptyOrderRepository(), new HierarchicalLifetimeManager());
              }
        }