コード例 #1
0
        public ActionResult New(GameMode modeSelect, int?variantSelect, int?aiSelect, string[] opponent)
        {
            VariantService    variants = GetService <VariantService>();
            VariantVersion    version;
            List <User>       opponentUsers;
            AIDifficultyModel aiDifficulty;

            if (!ValidateNewGame(modeSelect, variantSelect, aiSelect, opponent, variants, out version, out opponentUsers, out aiDifficulty))
            {
                var model = PopulateNewGameModel(variants);
                return(View(model));
            }

            var routeValues = new RouteValueDictionary();

            routeValues.Add("ID", version.Variant.Tag);

            if (!version.Variant.PublicVersionID.HasValue || version.Variant.PublicVersionID != version.ID)
            {
                routeValues.Add("version", version.Number);
            }

            switch (modeSelect)
            {
            case GameMode.Offline:
                return(RedirectToAction("Offline", routeValues));

            case GameMode.AI:
                routeValues.Add("difficulty", aiDifficulty.ID);
                return(RedirectToAction("AI", routeValues));

            default:
                throw new NotImplementedException("Not yet implemented creating " + modeSelect + " games");
            }
        }
コード例 #2
0
        public ActionResult Variants(string id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            UserService users        = GetService <UserService>();
            var         selectedUser = users.GetByName(id);

            if (selectedUser == null)
            {
                return(HttpNotFound());
            }

            VariantService variants = GetService <VariantService>();

            var model = new UserVariantsModel()
            {
                UserName = selectedUser.Name
            };

            model.IsCurrentUser = Request.IsAuthenticated && selectedUser.Name == User.Identity.Name;
            model.Variants      = variants.ListUserVariants(selectedUser, model.IsCurrentUser);

            return(View(model));
        }
コード例 #3
0
        public ActionResult Index()
        {
            VariantService service  = GetService <VariantService>();
            var            variants = service.ListVariants(User.Identity.Name);

            return(View(variants));
        }
コード例 #4
0
        public ActionResult AI_vs_AI(string id, int?version, int[] difficulty)
        {
            VariantService variants      = GetService <VariantService>();
            VariantVersion versionToPlay = DeterminePlayVersion(id, version, variants);

            if (versionToPlay == null)
            {
                return(HttpNotFound("Cannot determine variant version to play"));
            }

            var model = new GamePlayModel(versionToPlay, GameMode.AI_vs_AI);
            var AIs   = variants.ListAiDifficulties();

            model.Players = new PlayerModel[versionToPlay.Variant.PlayerCount];
            for (var i = 0; i < model.Players.Length && i < difficulty.Length; i++)
            {
                model.Players[i] = AIs.Single(ai => ai.ID == difficulty[i]);
            }

            for (var i = difficulty.Length; i < model.Players.Length; i++)
            {
                model.Players[i] = model.Players[difficulty.Length];
            }

            return(View("Play", model));
        }
コード例 #5
0
        public OrderViewModelBuilder(
            RequestModelAccessor requestModelAccessor,
            FieldDefinitionService fieldDefinitionService,
            LanguageService languageService,
            PaymentService paymentService,
            PageService pageServcie,
            UrlService urlService,
            ModuleECommerce moduleECommerce,
            SecurityToken securityToken,
            ProductModelBuilder productModelBuilder,
            VariantService variantService,
            UnitOfMeasurementService unitOfMeasurementService,
            OrganizationService organizationService,
            PersonStorage personStorage)
        {
            _requestModelAccessor   = requestModelAccessor;
            _fieldDefinitionService = fieldDefinitionService;
            _languageService        = languageService;
            _paymentService         = paymentService;
            _pageServcie            = pageServcie;
            _urlService             = urlService;

            _moduleECommerce          = moduleECommerce;
            _securityToken            = securityToken;
            _productModelBuilder      = productModelBuilder;
            _variantService           = variantService;
            _unitOfMeasurementService = unitOfMeasurementService;
            _organizationService      = organizationService;
            _personStorage            = personStorage;
        }
コード例 #6
0
        public ActionResult New()
        {
            VariantService variants = GetService <VariantService>();
            var            model    = PopulateNewGameModel(variants);

            return(View(model));
        }
コード例 #7
0
 public ProductCatalogStructurePackage(BaseProductService baseProductService, ProductListService productListService,
                                       RelationshipTypeService relationshipTypeService, CategoryService categoryService,
                                       UnitOfMeasurementService unitOfMeasurementService, DataService dataService,
                                       FieldTemplateService fieldTemplateService,
                                       LanguageService languageService, VariantService variantService,
                                       InventoryService inventoryService,
                                       PriceListService priceListService,
                                       StructureInfoService structureInfoService,
                                       CurrencyService currencyService,
                                       FilterService filterService,
                                       InventoryItemService inventoryItemService,
                                       PriceListItemService priceListItemService,
                                       ProductListItemService productListItemService)
 {
     _baseProductService        = baseProductService;
     _categoryService           = categoryService;
     _dataService               = dataService;
     _fieldTemplateService      = fieldTemplateService;
     _languageService           = languageService;
     _variantService            = variantService;
     _inventoryService          = inventoryService;
     _priceListService          = priceListService;
     _structureInfoService      = structureInfoService;
     _currencyService           = currencyService;
     _filterService             = filterService;
     _productListService        = productListService;
     _relationshipTypeService   = relationshipTypeService;
     _unitOfMeasurementService  = unitOfMeasurementService;
     _bidirectionalRelationList = new List <ImportBidirectionalRelation>();
     _inventoryItemService      = inventoryItemService;
     _priceListItemService      = priceListItemService;
     _productListItemService    = productListItemService;
 }
コード例 #8
0
 public ProductDemoService(BaseProductService baseProductService, FieldTemplateService fieldTemplateService, VariantService variantService, CategoryService categoryService)
 {
     _baseProductService   = baseProductService;
     _fieldTemplateService = fieldTemplateService;
     _variantService       = variantService;
     _categoryService      = categoryService;
 }
コード例 #9
0
 public ProductType(
     VariantService variantService,
     CategoryService categoryService,
     CurrencyService currencyService,
     ChannelService channelService,
     CountryService countryService,
     Web.Models.Products.ProductPriceModelBuilder productPriceModelBuilder,
     BaseProductService baseProductService,
     UrlService urlService)
 {
     Name        = "Product";
     Description = "A product";
     Field(p => p.SystemId, type: typeof(IdGraphType)).Description("The system Id");
     Field(p => p.Id).Description("The article number");
     Field(p => p.Name);
     Field(p => p.Images);
     Field(p => p.Brand, nullable: true);
     Field(p => p.Color);
     Field(p => p.Description);
     Field(p => p.IsInStock);
     Field(p => p.FormattedPrice);
     Field(p => p.ShowBuyButton);
     Field(p => p.ShowQuantityField);
     Field(p => p.Size);
     Field(p => p.StockStatusDescription);
     Field(p => p.Slug);
     Field(p => p.UseVariantUrl);
 }
コード例 #10
0
        public ActionResult DeleteVersion(int id)
        {
            var version = Entities().VariantVersions.Find(id);

            if (version == null)
            {
                return(HttpNotFound());
            }

            UserService users = GetService <UserService>();

            if (!users.IsAllowedToEdit(version.Variant, User.Identity.Name))
            {
                return(new HttpUnauthorizedResult());
            }

            int variantID = version.VariantID;

            VariantService variants = GetService <VariantService>();

            if (!variants.CanDelete(version))
            {
                return(new HttpUnauthorizedResult());
            }

            Entities().VariantVersions.Remove(version);
            Entities().SaveChanges();

            return(RedirectToAction("Edit", new { id = variantID }));
        }
コード例 #11
0
 public ProductsAreInStock(ModuleECommerce moduleECommerce, SecurityToken securityToken, IStockStatusCalculator stockStatusCalculator, VariantService variantService, RequestModelAccessor requestModelAccessor)
 {
     _moduleECommerce       = moduleECommerce;
     _securityToken         = securityToken;
     _stockStatusCalculator = stockStatusCalculator;
     _variantService        = variantService;
     _requestModelAccessor  = requestModelAccessor;
 }
コード例 #12
0
 public ProductServiceImpl(
     RelationshipTypeService relationshipTypeService,
     RelatedModelBuilder relatedModelBuilder,
     VariantService variantService)
 {
     _relationshipTypeService = relationshipTypeService;
     _relatedModelBuilder     = relatedModelBuilder;
 }
コード例 #13
0
        public string uploadImageVariant(int id, HttpPostedFileBase imageVariant)
        {
            string strMessage = "upload0";

            try
            {
                if (imageVariant != null)
                {
                    if (imageVariant.ContentLength / 1024 / 1024 > 1)
                    {
                        strMessage = "upload2";
                    }
                    else if (imageVariant.ContentLength > 0)
                    {
                        VariantService variantService = new VariantService();
                        Variant        variant        = variantService.GetByPrimaryKey(id);
                        if (variant != null)
                        {
                            string folder = Server.MapPath("~/assets/uploads/products/") + variant.ProductID;
                            Directory.CreateDirectory(folder);

                            string path = Path.Combine(folder, Path.GetFileName(imageVariant.FileName));
                            imageVariant.SaveAs(path);

                            string strWhere = "";
                            strWhere = "ImageName like N'" + imageVariant.FileName + "' and ProductID = " + variant.ProductID;
                            TblImage imageOfProduct = imageService.SelectByWhere(strWhere).FirstOrDefault();
                            if (imageOfProduct == null || imageOfProduct.ImageID <= 0)
                            {
                                string imageUrl = "";
                                imageUrl = HttpContext.Request.Url.Authority == string.Empty ? Common.UrlHost : "http://" + HttpContext.Request.Url.Authority;
                                if (!imageUrl.EndsWith("/"))
                                {
                                    imageUrl += "/";
                                }
                                imageUrl += "assets/uploads/products/" + variant.ProductID + "/" + imageVariant.FileName;

                                TblImage image = new TblImage();
                                image.ImageName = imageVariant.FileName;
                                image.ImageUrl  = imageUrl;
                                image.ImageSize = imageVariant.ContentLength;
                                image.ProductID = variant.ProductID;
                                int imageID = imageService.Insert(image);

                                variant.ImageID = imageID;
                                variantService.Update(variant);
                                strMessage = "upload1";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogService.WriteException(ex);
            }
            return(strMessage);
        }
コード例 #14
0
        private NewGameModel PopulateNewGameModel(VariantService service)
        {
            var model = new NewGameModel();

            model.Variants        = service.ListPlayableVersions(User.Identity.Name);
            model.Difficulties    = service.ListAiDifficulties();
            model.AllowOnlinePlay = User.Identity.IsAuthenticated;
            return(model);
        }
 public ODataProductsController(DataService dataService, VariantService variantService,
                                PriceListItemService priceListItemService,
                                PriceListService priceListService)
 {
     this.dataService          = dataService;
     this.variantService       = variantService;
     this.priceListItemService = priceListItemService;
     this.priceListService     = priceListService;
 }
コード例 #16
0
 public MostSoldEventListener(MostSoldDataHolder mostSoldDataHolder, EventBroker eventBroker, CategoryService categoryService, VariantService variantService, ChannelService channelService, MarketService marketService)
 {
     _mostSoldDataHolder = mostSoldDataHolder;
     _eventBroker        = eventBroker;
     _categoryService    = categoryService;
     _variantService     = variantService;
     _token          = Solution.Instance.SystemToken;
     _channelService = channelService;
     _marketService  = marketService;
 }
コード例 #17
0
 public ProductEventListener(
     EventBroker eventBroker,
     IndexQueueService indexQueueService,
     VariantService variantService,
     CategoryService categoryService)
 {
     _eventBroker       = eventBroker;
     _indexQueueService = indexQueueService;
     _variantService    = variantService;
     _categoryService   = categoryService;
 }
コード例 #18
0
ファイル: OrderUtilities.cs プロジェクト: Salle79/Accelerator
 public OrderUtilities(
     CartAccessor cartAccessor,
     VariantService variantService,
     InventoryItemService inventoryItemService,
     IStockStatusCalculator stockStatusCalculator)
 {
     _stockStatusCalculator = stockStatusCalculator;
     _inventoryItemService  = inventoryItemService;
     _cartAccessor          = cartAccessor;
     _variantService        = variantService;
 }
コード例 #19
0
 public CategoryDemoService(CategoryService categoryService,
                            FieldTemplateService fieldTemplateService, ISuggestionService suggestionService,
                            VariantService variantService, ChannelService channelService)
 {
     _categoryService      = categoryService;
     _fieldTemplateService = fieldTemplateService;
     _suggestionService    = suggestionService;
     _variantService       = variantService;
     _channelService       = channelService;
     _categoryLookup       = new Dictionary <string, Category>();
 }
コード例 #20
0
        public ActionResult Definition(string id, int?version)
        {
            VariantService variants      = GetService <VariantService>();
            VariantVersion versionToPlay = DeterminePlayVersion(id, version, variants);

            if (versionToPlay == null)
            {
                return(HttpNotFound("Cannot determine variant version to play"));
            }

            return(Content(versionToPlay.Definition, "text/xml"));
        }
コード例 #21
0
 public CartViewModelBuilder(CartService cartService, RequestModelAccessor requestModelAccessor, UrlService urlService,
                             VariantService variantService, BaseProductService baseProductService, ModuleECommerce moduleECommerce,
                             UnitOfMeasurementService unitOfMeasurementService)
 {
     _cartService              = cartService;
     _requestModelAccessor     = requestModelAccessor;
     _urlService               = urlService;
     _variantService           = variantService;
     _baseProductService       = baseProductService;
     _moduleECommerce          = moduleECommerce;
     _unitOfMeasurementService = unitOfMeasurementService;
 }
コード例 #22
0
 public ProductsAreInStock(
     IStockStatusCalculator stockStatusCalculator,
     SecurityContextService securityContextService,
     CountryService countryService,
     VariantService variantService,
     CartContextAccessor cartContextAccessor)
 {
     _stockStatusCalculator  = stockStatusCalculator;
     _securityContextService = securityContextService;
     _countryService         = countryService;
     _variantService         = variantService;
     _cartContextAccessor    = cartContextAccessor;
 }
コード例 #23
0
 public ProductBlockViewModelBuilder(ProductModelBuilder productModelBuilder,
                                     ProductItemViewModelBuilder productItemViewModelBuilder,
                                     RequestModelAccessor requestModelAccessor,
                                     ProductSearchService productSearchService,
                                     BaseProductService baseProductService,
                                     VariantService variantService)
 {
     _productModelBuilder         = productModelBuilder;
     _productItemViewModelBuilder = productItemViewModelBuilder;
     _requestModelAccessor        = requestModelAccessor;
     _productSearchService        = productSearchService;
     _baseProductService          = baseProductService;
     _variantService = variantService;
 }
コード例 #24
0
 public SearchResultTransformationService(
     BaseProductService baseProductService,
     VariantService variantService,
     FieldDefinitionService fieldDefinitionService,
     ProductModelBuilder productModelBuilder,
     UrlService urlService,
     CategoryService categoryService)
 {
     _baseProductService     = baseProductService;
     _variantService         = variantService;
     _fieldDefinitionService = fieldDefinitionService;
     _productModelBuilder    = productModelBuilder;
     _urlService             = urlService;
     _categoryService        = categoryService;
 }
コード例 #25
0
 public MediaMapper(BaseProductService baseProductService,
                    VariantService variantService,
                    FieldDefinitionService fieldDefinitionService,
                    MediaArchive mediaArchive,
                    IEnumerable <IFieldSetter> fieldSetters,
                    IMediaProfiler mediaProfiler,
                    string mediaUploadFolder)
 {
     _baseProductService     = baseProductService;
     _variantService         = variantService;
     _fieldDefinitionService = fieldDefinitionService;
     _mediaArchive           = mediaArchive;
     _mediaProfiler          = mediaProfiler;
     _fieldSetters           = fieldSetters.ToList();
     _uploadFolder           = mediaUploadFolder?.Replace('\\', '/').Trim('/');
 }
コード例 #26
0
 public VariantInfoBuilder(
     VariantService variantService,
     FileService fileService,
     ProductPriceModelBuilder priceModelBuilder,
     WebsiteService websiteService,
     CurrencyService currencyService,
     ChannelService channelService,
     PriceListItemService priceListItemService)
 {
     _variantService       = variantService;
     _fileService          = fileService;
     _priceModelBuilder    = priceModelBuilder;
     _currencyService      = currencyService;
     _channelService       = channelService;
     _priceListItemService = priceListItemService;
 }
コード例 #27
0
        public async Task InitializeAsync()
        {
            var policy = new SmartRetryExecutionPolicy();

            Service.SetExecutionPolicy(policy);
            VariantService.SetExecutionPolicy(policy);

            // Get a product id to use with these tests.
            ProductId = (await new ProductService(Utils.MyShopifyUrl, Utils.AccessToken).ListAsync(new ProductFilter()
            {
                Limit = 1
            })).First().Id.Value;

            // Create one for use with count, list, get, etc. tests.
            await Create();
        }
コード例 #28
0
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <ProductVariant> Create(string option1 = null, bool skipAddToCreatedList = false)
        {
            var obj = await VariantService.CreateAsync(ProductId, new ProductVariant()
            {
                Option1             = Guid.NewGuid().ToString(),
                Price               = Price,
                InventoryManagement = "shopify",
                SKU = "Some sku"
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
コード例 #29
0
 public CartViewModelBuilder(
     RequestModelAccessor requestModelAccessor,
     UrlService urlService,
     ChannelService channelService,
     CurrencyService currencyService,
     BaseProductService baseProductService,
     VariantService variantService,
     UnitOfMeasurementService unitOfMeasurementService)
 {
     _requestModelAccessor     = requestModelAccessor;
     _urlService               = urlService;
     _channelService           = channelService;
     _currencyService          = currencyService;
     _baseProductService       = baseProductService;
     _variantService           = variantService;
     _unitOfMeasurementService = unitOfMeasurementService;
 }
コード例 #30
0
 public VariantInfoBuilder(
     VariantService variantService,
     ProductPriceModelBuilder priceModelBuilder,
     CurrencyService currencyService,
     ChannelService channelService,
     CountryService countryService,
     CartContextAccessor cartContextAccessor,
     RequestModelAccessor requestModelAccessor)
 {
     _variantService       = variantService;
     _priceModelBuilder    = priceModelBuilder;
     _currencyService      = currencyService;
     _channelService       = channelService;
     _countryService       = countryService;
     _cartContextAccessor  = cartContextAccessor;
     _requestModelAccessor = requestModelAccessor;
 }