/// <summary>
        /// Core Feature validation
        /// </summary>
        /// <returns>True if valid; false otherwise</returns>
        /// <exception cref="BadInternalErrorException"></exception>
        internal static void ValidateFeatures(ProductFeature requiredProductFeature = ProductFeature.None)
        {
            var valid = CheckLicense();

            if (!LicenseTraceDone)
            {
                LicenseTraceDone = true;
                Utils.Trace("Used Product = {0}, Features = {1}, Version = {2}.", Product, LicensedFeatures, Version);
            }

            if (!valid && !IsLicensed)
            {
                throw new BadInternalErrorException("Evaluation time expired! You need to restart the application.");
            }
            if (!valid)
            {
                throw new BadInternalErrorException("License required! You can't use this feature.");
            }

            if (requiredProductFeature != ProductFeature.None && LicensedFeatures != ProductFeature.AllFeatures)
            {
                if ((requiredProductFeature & LicensedFeatures) != requiredProductFeature)
                {
                    var message =
                        $"Feature {requiredProductFeature} required but only {LicensedFeatures} licensed! You can't use this feature.";
                    throw new BadInternalErrorException(message);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// This adds the missing product features
        /// </summary>
        /// <param name="iproduct"></param>
        /// <param name="productFeaturesToBeAdded"></param>
        private void addProductFeaturesTo(IProduct iproduct, List <ProductFeature> productFeaturesToBeAdded)
        {
            if (productFeaturesToBeAdded.IsNullOrEmpty())
            {
                return;
            }

            Product product = iproduct as Product;

            product.IsNullThrowException("could not unbox product");


            //incase ProductFeatures is null.
            if (product.ProductFeatures.IsNull())
            {
                product.ProductFeatures = new List <ProductFeature>();
            }

            string productId = product.Id;

            foreach (ProductFeature pf in productFeaturesToBeAdded)
            {
                //locate feature in product... if it is not a part of it.. add it
                ProductFeature pfFound = product.ProductFeatures.FirstOrDefault(x => x.Name == pf.Name && x.MetaData.IsDeleted == false);

                if (pfFound.IsNull())
                {
                    pf.ProductId = product.Id;
                    product.ProductFeatures.Add(pf);
                }
            }
        }
예제 #3
0
 public ActionResult Create(int?id, ProductFeature productFeature)
 {
     productFeature.ProductId = id.Value;
     _productFeatureRepository.Insert(productFeature);
     _productFeatureRepository.Save();
     return(RedirectToAction("Index", new { id = id.Value }));
 }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("FeatureId,Feature,ProductId")] ProductFeature productFeature)
        {
            if (id != productFeature.FeatureId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productFeature);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductFeatureExists(productFeature.FeatureId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", productFeature.ProductId);
            return(View(productFeature));
        }
예제 #5
0
        protected override void Seed(MyContext context)
        {
            Random rnd = new Random();

            for (int i = 0; i < 5; i++)
            {
                Category c = new Category();

                c.CategoryName = new Commerce("tr").Categories(1)[0];
                c.Description  = new Lorem("tr").Sentence(100);
                context.Categories.Add(c);
                context.SaveChanges();
                for (int j = 0; j < 10; j++)
                {
                    Product p = new Product();

                    p.ProductName  = new Commerce("tr").ProductName();
                    p.UnitPrice    = Convert.ToDecimal(new Commerce("tr").Price());
                    p.UnitsInStock = rnd.Next(5, 500);
                    p.ImagePath    = new Images().City();


                    context.Products.Add(p);
                    context.SaveChanges();


                    ProductCategory pc = new ProductCategory();
                    pc.ProductID  = p.ID;
                    pc.CategoryID = c.ID;
                    context.ProductCategories.Add(pc);
                    context.SaveChanges();


                    if (i == 4)
                    {
                        ProductCategory pc2 = new ProductCategory();
                        pc2.ProductID  = p.ID;
                        pc2.CategoryID = c.ID - 1;
                        context.ProductCategories.Add(pc2);
                    }
                    context.SaveChanges();

                    for (int k = 0; k < 20; k++)
                    {
                        Feature f = new Feature();
                        f.FeatureName = new Commerce("tr").ProductMaterial();
                        f.Description = new Lorem("tr").Sentence(4);
                        context.Features.Add(f);
                        context.SaveChanges();

                        ProductFeature pf = new ProductFeature();
                        pf.ProductID = p.ID;
                        pf.FeatureID = f.ID;
                        pf.Value     = new Commerce("tr").Color();
                        context.ProductFeatures.Add(pf);
                        context.SaveChanges();
                    }
                }
            }
        }
예제 #6
0
    public CompanyTaskUpgradeFeature(int companyId, ProductFeature improvement)
    {
        CompanyId       = companyId;
        CompanyTaskType = CompanyTaskType.UpgradeFeature;

        ProductImprovement = improvement;
    }
예제 #7
0
        public void FeatureTest()
        {
            var t = ProductFeature.Random();

            Obj.UniqueId = t.UniqueId;
            ProductFeatures.Instance.Add(t);
            Assert.AreEqual(t, Obj.Feature);
        }
        public void EditProductFeature(ProductFeature productFeature)
        {
            var oldProductFeature = _storeUnitOfWork.ProductFeatureRepository.GetById(productFeature.Id);

            oldProductFeature.Name        = productFeature.Name;
            oldProductFeature.Description = productFeature.Description;
            _storeUnitOfWork.Save();
        }
예제 #9
0
 private static bool IsShared(ProductFeature feature) =>
 feature == ProductFeature.CampaignDeliveryType ||
 feature == ProductFeature.DeliveryCappingGroup ||
 feature == ProductFeature.LandmarkBooking ||
 feature == ProductFeature.SalesAreaZeroRevenueSplit ||
 feature == ProductFeature.TargetSalesArea ||
 feature == ProductFeature.ZeroRatedBreaksMapping ||
 feature == ProductFeature.InventoryStatus;
 public ProductFeatureDto MapperToProductFeatureDto(ProductFeature productFeature)
 {
     return(new ProductFeatureDto
     {
         Id = productFeature.Id,
         Description = productFeature.Description,
         Title = productFeature.Title
     });
 }
예제 #11
0
        /// <summary>
        /// Returns true if the specified <see cref="ProductFeature"/> value is enabled, otherwise false.
        /// </summary>
        public static bool IsEnabled(this IFeatureManager featureManager, ProductFeature feature)
        {
            if (featureManager is null)
            {
                throw new ArgumentNullException(nameof(featureManager));
            }

            return(featureManager.IsEnabled(feature.ToString()));
        }
예제 #12
0
 public IActionResult Create(ProductFeature productFeature)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     kavanContext.ProductFeatures.Add(productFeature);
     kavanContext.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #13
0
 public ActionResult Edit(ProductFeature productFeature)
 {
     if (!ModelState.IsValid)
     {
         return(View(productFeature));
     }
     _productFeatureRepository.Update(productFeature);
     _productFeatureRepository.Save();
     return(RedirectToAction("Index", new { id = productFeature.ProductId }));
 }
예제 #14
0
        public void AddProductFeature(ProductFeature productFeature)
        {
            checkIfProductExists(productFeature.ProductId);
            checkIfProductAlreadyHasFeature(productFeature.FeatureId, productFeature.ProductId);
            Feature feature = getFeature(productFeature.FeatureId);

            productFeature.Validate();
            productFeature.CheckIfValueCorrespondsToType(feature);
            this.productFeatureRepo.Add(productFeature);
        }
예제 #15
0
        private void checkIfProductAlreadyHasFeature(Guid featureId, Guid productId)
        {
            List <ProductFeature> allProductFeatures = productFeatureRepo.GetAll();
            ProductFeature        existing           = allProductFeatures.Find(pf => pf.ProductId == productId && pf.FeatureId == featureId);

            if (existing != null)
            {
                throw new ProductFeatureDuplicateFeature("Este producto ya tiene un valor para este atributo");
            }
        }
예제 #16
0
        // TODO move to separate file/delete
        public static void UpgradeFeatures(ProductFeature improvement, GameEntity product, GameContext gameContext)
        {
            var task = new CompanyTaskUpgradeFeature(product.company.Id, improvement);

            if (CanUpgradeFeature(improvement, product, gameContext, task))
            {
                product.expertise.ExpertiseLevel--;
                Cooldowns.AddCooldown(gameContext, task, 8);
            }
        }
예제 #17
0
 public static ProductFeature Update(ProductFeature model)
 {
     model.UpdateDate = DateTime.Now;
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
     }
     return(model);
 }
예제 #18
0
        public static ProductFeature GetById(int id)
        {
            var data = new ProductFeature();

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                data = db.ProductFeatures.FirstOrDefault(x => x.Id == id);
            }
            return(data);
        }
 public ActionResult Create(ProductFeature productFeature, int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     productFeature.ProductId = id.Value;
     _productFeatureRepository.Insert(productFeature);
     _productFeatureRepository.Save();
     return(RedirectToAction("Index", new { id = id.Value }));
 }
예제 #20
0
 public static ProductFeature Add(ProductFeature model)
 {
     model.CreateDate = DateTime.Now;
     model.IsDelete   = false;
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         db.ProductFeatures.Add(model);
         db.SaveChanges();
     }
     return(model);
 }
        public ProductFeature DeleteFeature(int productFeatureId)
        {
            ProductFeature dbEntry = context.ProductFeatures.Find(productFeatureId);

            if (dbEntry != null)
            {
                context.ProductFeatures.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
예제 #22
0
        public void FindTest()
        {
            var s = GetRandom.String();

            Assert.IsNull(ProductFeatures.Find(s));
            var t = ProductFeature.Random();

            t.UniqueId = s;
            ProductFeatures.Instance.Add(t);
            ProductFeatures.Instance.AddRange(ProductFeatures.Random());
            Assert.AreEqual(t, ProductFeatures.Find(s));
        }
예제 #23
0
        public ActionResult ProductFeature(ProductFeature feature)
        {
            if (ModelState.IsValid)
            {
                DatabaseContext.ProductFeatures.Add(feature);
                DatabaseContext.SaveChanges();

                return(RedirectToAction("ProductFeature", new { id = feature.ProductId }));
            }

            return(View(feature));
        }
예제 #24
0
        public async Task <IActionResult> Create([Bind("FeatureId,Feature,ProductId")] ProductFeature productFeature)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productFeature);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", productFeature.ProductId);
            return(View(productFeature));
        }
        public ActionResult Edit(int?id, ProductFeature productFeature)
        {
            if (!ModelState.IsValid)
            {
                return(View(productFeature));
            }
            var feature = _productFeatureRepository.GetById(id.Value);

            _productFeatureRepository.Update(productFeature);
            _productFeatureRepository.Save();
            return(RedirectToAction("Index", new { id = feature.ProductId }));
        }
예제 #26
0
        public void RemoveFeatureFromProduct(Guid pId, Guid fId)
        {
            checkIfProductExists(pId);
            Feature savedFeature = getFeature(fId);
            List <ProductFeature> allProductFeatures = productFeatureRepo.GetAll();
            ProductFeature        existing           = allProductFeatures.Find(pf => pf.ProductId == pId && pf.FeatureId == fId);

            if (existing == null)
            {
                throw new ProductWithoutFeatureException("Este producto no está asociado a este atributo");
            }
            productFeatureRepo.Delete(existing);
        }
예제 #27
0
        public ActionResult Create(
            AdminEditViewModel model, HttpPostedFileBase productImg = null)
        {
            if (ModelState.IsValid)
            {
                // сохраняем товар
                Product product      = model.Product;
                bool    isImageValid = validateImage(productImg);
                if (isImageValid)
                {
                    product.ImageMimeType = productImg.ContentType;
                    product.ImageData     = resizeImage(productImg);
                }
                else
                {
                    Category productCategory = categoryRepo.Categories.Single(c => c.Name == product.Category);
                    product.ImageMimeType = productCategory.ImageMimeType;
                    product.ImageData     = productCategory.ImageData;
                }
                productRepo.SaveProduct(product);

                /////////////////////////////// processing description features table ///////////////////////////////
                if (model.DescriptionFeatures?.Count > 0)
                {
                    foreach (var descFeature in model.DescriptionFeatures)
                    {
                        // добавляем принадлежность к товару
                        descFeature.ProductId = product.ProductID;
                        descriptionFeatureRepo.SaveFeature(descFeature);
                    }
                }

                // сохраняем features
                if (model.ProductFeatures?.Count > 0)
                {
                    foreach (var feature in model.ProductFeatures)
                    {
                        var productFeature = new ProductFeature
                        {
                            Name      = feature.Name,
                            Value     = feature.Value,
                            Unit      = feature.Unit,
                            ProductId = product.ProductID
                        };
                        productFeatureRepo.SaveFeature(productFeature);
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
예제 #28
0
        public ActionResult AddProduct([Bind(Prefix = "item1")] Product item, FormCollection koleksiyon)
        {
            if (item != null || koleksiyon != null)
            {
                prep.Add(item);

                var kategoriler = koleksiyon["kategoriler"];
                #region Açıklama

                /*
                 * Koleksiyon tüm girdileri taşıdığı yani product nesnesinin de girdilerini taşıdığı ve product nesnesinin zorunlu alanlar olduğu için koleksiyon null gelmiyor. Koleksiyon null gelmese de kategoriler ve özellikler null gelebilir. Çünkü bu alanlar zorunlu alanlardan değil.
                 */
                #endregion

                if (kategoriler != null)
                {
                    foreach (char kategori in kategoriler)
                    {
                        if (kategori != 44)
                        {
                            ProductCategory pc = new ProductCategory();

                            pc.CategoryID = Convert.ToInt32(kategori.ToString());
                            pc.ProductID  = item.ID;
                            pcrep.Add(pc);
                        }
                    }
                }

                var ozellikler = koleksiyon["ozellikler"];

                if (ozellikler != null)
                {
                    foreach (char ozellik in ozellikler)
                    {
                        if (ozellik != 44)
                        {
                            ProductFeature pf = new ProductFeature();

                            pf.FeatureID = Convert.ToInt32(ozellik.ToString());
                            pf.ProductID = item.ID;
                            pfrep.Add(pf);
                        }
                    }
                }

                return(RedirectToAction("Detail", new { id = item.ID }));   //Admin ürün ekledikten sonra özeliklere değer atayabilmesi için detail sayfasına ürünün id'si ile birlikte yönlendirildi
            }
            ViewBag.Hata = "Ürün ekleme sırasında hata oluştu.";
            return(View());
        }
예제 #29
0
        public void ModifyProductFeatureValue(Guid id, string val)
        {
            ProductFeature productFeature = productFeatureRepo.Get(id);

            if (productFeature != null)
            {
                productFeature.Value = val;
                productFeature.Validate();
                Feature feature = getFeature(productFeature.FeatureId);
                productFeature.CheckIfValueCorrespondsToType(feature);
                productFeatureRepo.Update(productFeature);
            }
            else
            {
                throw new NoProductFeatureException("No hay atributo de producto con este id");
            }
        }
예제 #30
0
        private void markRequiredFeaturesAsDeleteNotAllowed(IProduct iproduct, List <MenuFeature> allfeautresAsPerMenuPath)
        {
            if (iproduct.ProductFeatures.IsNullOrEmpty())
            {
                return;
            }
            if (allfeautresAsPerMenuPath.IsNullOrEmpty())
            {
                return;
            }

            foreach (MenuFeature menuFeature in allfeautresAsPerMenuPath)
            {
                ProductFeature productFeatureRequired = iproduct.ProductFeatures.FirstOrDefault(x => x.MetaData.IsDeleted == false && x.Name == menuFeature.Name);
                productFeatureRequired.MetaData.IsDeleteLocked = true;
            }
        }
        public void PrepareForSave(LoanApplication loanApplication, DateTime today)
        {
            if (this.IsNew)
            {
                ProductFeatureApplicability featureApp;
                if (this.IsFromPickList == false)
                {
                    ProductFeature feature = ProductFeature.GetByName(this.Name);
                    if (feature == null)
                    {
                        feature = new ProductFeature();
                        feature.Name = this.Name;
                        feature.ProductFeatureCategory = ProductFeatureCategory.FeeType;
                        Context.ProductFeatures.AddObject(feature);
                    }

                    FinancialProduct financialProduct = FinancialProduct.GetById(this.FinancialProductId);
                    featureApp = ProductFeatureApplicability.GetActive(feature, financialProduct);
                    if (featureApp == null)
                        featureApp = ProductFeatureApplicability.Create(feature, financialProduct, today);

                }
                else
                {
                    featureApp = ProductFeatureApplicability.GetById(this.ProductFeatureApplicabilityId);
                }

                ApplicationItem item = new ApplicationItem();
                item.Application = loanApplication.Application;
                item.ProductFeatureApplicability = featureApp;
                item.FeeComputedValue = this.TotalChargePerFee;
                item.EffectiveDate = today;

                LoanApplicationFee fee = new LoanApplicationFee();
                fee.LoanApplication = loanApplication;
                fee.Particular = this.Name;
                fee.Amount = this.Amount;
                //fee.ApplicationItem = item;

                Context.LoanApplicationFees.AddObject(fee);
                Context.ApplicationItems.AddObject(item);
            }
            else if (this.ToBeDeleted)
            {
                LoanApplicationFee applicationFee = Context.LoanApplicationFees.SingleOrDefault(entity => entity.Id == this.LoanApplicationFeeId);
                if (applicationFee != null)
                {
                    var application = applicationFee.LoanApplication.Application;
                    var productFeature = ProductFeature.GetByName(applicationFee.Particular);
                    var applicationItem = ApplicationItem.Get(application, productFeature);
                    applicationItem.EndDate = today;
                    Context.LoanApplicationFees.DeleteObject(applicationFee);
                }
            }
            else if (this.IsNew == false && this.ToBeDeleted == false)
            {
                ProductFeatureApplicability featureApp;
                if (this.IsFromPickList == false)
                {
                    ProductFeature feature = ProductFeature.GetByName(this.Name);
                    if (feature == null)
                    {
                        feature = new ProductFeature();
                        feature.Name = this.Name;
                        feature.ProductFeatureCategory = ProductFeatureCategory.FeeType;
                        Context.ProductFeatures.AddObject(feature);
                    }

                    FinancialProduct financialProduct = FinancialProduct.GetById(this.FinancialProductId);
                    featureApp = ProductFeatureApplicability.GetActive(feature, financialProduct);
                    if (featureApp == null)
                        featureApp = ProductFeatureApplicability.Create(feature, financialProduct, today);

                }
                else
                {
                    featureApp = ProductFeatureApplicability.GetById(this.ProductFeatureApplicabilityId);
                }

                ApplicationItem item = new ApplicationItem();
                item.Application = loanApplication.Application;
                item.ProductFeatureApplicability = featureApp;
                item.FeeComputedValue = this.TotalChargePerFee;
                item.EffectiveDate = today;

                LoanApplicationFee fee = new LoanApplicationFee();
                fee.LoanApplication = loanApplication;
                fee.Particular = this.Name;
                fee.Amount = this.Amount;
                //fee.ApplicationItem = item;

                Context.LoanApplicationFees.AddObject(fee);
                Context.ApplicationItems.AddObject(item);
            }
        }