Пример #1
0
        public Response Create(NewCategories categories)
        {
            Response response = new Response();

            try
            {
                using (IDbConnection conn = GetConnection())
                {
                    var        merchant = conn.Get <Merchants>(categories.MerchantId);
                    Categories cat      = new Categories()
                    {
                        CategoryName = categories.CategoryName,
                        Description  = categories.Description,
                        MerchantId   = categories.MerchantId,
                        MerchantName = merchant.MerchantName,
                        Picture      = categories.Picture
                    };
                    conn.Insert(cat);
                    response.Status      = true;
                    response.Description = "Record saved";
                }
            }
            catch (Exception ex)
            {
                response.Description = ex.Message;
                response.Status      = false;
            }
            return(response);
        }
Пример #2
0
        public ActionResult UpdateCate(NewCategories model)
        {
            var session = Session["session"] as GlobSession;

            if (session != null)
            {
                var manager = ServiceFactory.GetService <NewCategories>(session) as NewCategoriesManager;
                var obj     = manager.Get(new NewCategories {
                    NewCategoryId = model.NewCategoryId
                });
                if (obj != null)
                {
                    model.NewCategoryShortName = model.NewCategoryName.ToUrlSegment(250).ToLower();
                    obj.NewCategoryKeyword     = model.NewCategoryKeyword;
                    obj.NewCategoryName        = model.NewCategoryName;
                    obj.NewCategoryShortName   = model.NewCategoryShortName;
                    obj.NewCategorySummary     = model.NewCategorySummary;
                    obj.OrderNo = model.OrderNo;
                    obj.Enable  = model.Enable;
                    manager.Update(obj);
                    return(RedirectToAction("SearchCate"));
                }
                return(View());
            }
            else
            {
                return(RedirectToAction("Login", "Account", new { returnUrl = Url.Action("UpdateCate") }));
            }
        }
Пример #3
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form newCategories = new NewCategories(this);

            newCategories.Focus();
            newCategories.ShowDialog();
        }
Пример #4
0
        public ActionResult CreateCate()
        {
            var session = Session["session"] as GlobSession;

            if (session != null)
            {
                NewCategories data = new NewCategories();
                return(View("UpdateCate", data));
            }
            else
            {
                return(RedirectToAction("Login", "Account", new { returnUrl = Url.Action("CreateCate") }));
            }
        }
Пример #5
0
    /// <summary>
    /// Resets List of new categories and assign to it new values.
    /// </summary>
    protected void CategorySelector_OnSelectionChanged(object sender, EventArgs e)
    {
        // Clear list of new categories
        NewCategories.Clear();

        foreach (int categoryId in CategorySelector.SelectedCategories.Keys)
        {
            if (CategorySelector.SelectedCategories[categoryId] != VariantOptionInfo.ExistingUnselectedOption)
            {
                NewCategories.Add(categoryId);
            }
        }

        // Reset selected items in UniGrid
        VariantGrid.SelectedItems = new List <string>();
    }
Пример #6
0
        public ActionResult CreateCate(NewCategories model)
        {
            var session = Session["session"] as GlobSession;

            if (session != null)
            {
                model.NewCategoryShortName = model.NewCategoryName.ToUrlSegment(250).ToLower();
                var manager = ServiceFactory.GetService <NewCategories>(session) as NewCategoriesManager;
                manager.Add(model);
                return(RedirectToAction("SearchCate", "New"));
            }
            else
            {
                return(RedirectToAction("Login", "Account", new { returnUrl = Url.Action("CreateCate") }));
            }
        }
Пример #7
0
        private void OnAddNewCategory(object obj)
        {
            if (string.IsNullOrEmpty(NewCategory) && obj.IsNull())
            {
                return;
            }

            string newCategory = obj.IsNull() ? NewCategory : (obj as UICategoryEntity).Name;

            if (!NewCategories.FirstOrDefault(category => 0 == string.Compare(newCategory, category, true)).IsNull())
            {
                MessageBox.Show($"Category \"{newCategory}\" exist!");
                return;
            }

            NewCategories.Add(newCategory);
            NewCategory = string.Empty;
        }
Пример #8
0
    /// <summary>
    /// Resets List of new categories and assign to it new values.
    /// </summary>
    protected void CategorySelector_OnSelectionChanged(object sender, EventArgs e)
    {
        // Clear list of new categories
        NewCategories.Clear();

        // Get selected categories from all available categories list to preserve right order
        var orderedCategories = mAllCategoriesOptions.Where(c => CategorySelector.SelectedCategories.Keys.Any(cID => c.Item1.CategoryID == cID));

        foreach (int categoryId in orderedCategories.Select(c => c.Item1.CategoryID))
        {
            if (CategorySelector.SelectedCategories[categoryId] != VariantOptionInfo.ExistingUnselectedOption)
            {
                NewCategories.Add(categoryId);
            }
        }

        // Reset selected items in UniGrid
        VariantGrid.SelectedItems = new List <string>();
    }
Пример #9
0
 private void OnRemoveNewCategory(object obj)
 {
     NewCategories.Remove(obj.ToString());
 }
Пример #10
0
    /// <summary>
    /// Generates variants asynchronous.
    /// </summary>
    /// <param name="parameter">AsyncControl parameters</param>
    private void GenerateAndSave(object parameter)
    {
        try
        {
            // Regenerate already existing variants
            if (mRegenerateVariants)
            {
                ProductAttributeSet   productAttributeSet = new ProductAttributeSet(CategorySelector.SelectedCategories.Values.Where(x => x > VariantOptionInfo.NewOption));
                List <ProductVariant> existingVariants    = VariantHelper.AddNewCategoriesToVariantsOfProduct(ProductID, productAttributeSet);

                // Use special action contexts to turn off unnecessary actions
                using (ECommerceActionContext eCommerceContext = new ECommerceActionContext())
                {
                    eCommerceContext.TouchParent            = false;
                    eCommerceContext.SetLowestPriceToParent = false;

                    existingVariants.ForEach(pVariant =>
                    {
                        AddLog(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(pVariant.Variant.SKUName)) + GetString("com.variants.isredefined"));
                        VariantHelper.SetProductVariant(pVariant);
                    });
                }

                // Save variant to update parent SKULastModified a SKUPrice properties
                var lastVariant = existingVariants.LastOrDefault();
                if (lastVariant != null)
                {
                    lastVariant.Variant.Generalized.SetObject();
                }
            }

            // Generate non-existing variants
            ProductVariant productVariant = null;

            // Use special action contexts to turn off unnecessary actions
            using (ECommerceActionContext eCommerceContext = new ECommerceActionContext())
            {
                eCommerceContext.TouchParent            = false;
                eCommerceContext.SetLowestPriceToParent = false;

                foreach (DataRow row in mVariantsToGenerate)
                {
                    IEnumerable <int> options = GetAllOptions(row, NewCategories.Union(ExistingCategories));
                    productVariant = new ProductVariant(ProductID, new ProductAttributeSet(options));
                    AddLog(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(productVariant.Variant.SKUName)) + GetString("com.variants.isdefined"));
                    productVariant.Set();
                }
            }

            // Save variant to update parent SKULastModified a SKUPrice properties
            if (productVariant != null)
            {
                productVariant.Variant.Generalized.SetObject();
            }
        }
        catch (Exception ex)
        {
            CurrentError = GetString("com.variant.definerror");
            EventLogProvider.LogException("Variant definition", "DEFINEVARIANT", ex);
        }
    }
Пример #11
0
    /// <summary>
    /// Generates variants into DataSet and DataTable.
    /// </summary>
    /// <returns>DataSet of generated variants</returns>
    private DataSet GenerateVariants()
    {
        List <ProductVariant> productVariantList;

        // Creating new variants and some has been already generated
        if ((NewCategories.Count > 0) && (ExistingCategories.Count > 0))
        {
            ProductAttributeSet   productAttributeSet = new ProductAttributeSet(CategorySelector.SelectedCategories.Values.Where(x => x > VariantOptionInfo.NewOption));
            List <ProductVariant> oldVariants         = VariantHelper.AddNewCategoriesToVariantsOfProduct(ProductID, productAttributeSet);
            productVariantList = VariantHelper.GetAllPossibleVariants(oldVariants);
        }
        else
        {
            productVariantList = VariantHelper.GetAllPossibleVariants(ProductID, NewCategories.Concat(ExistingCategories));
        }

        DataSet   ds = new DataSet("VariantsDS");
        DataTable dt = new DataTable("VariantsDT");

        // Combine new and existing categories in right order
        var combinedCategories = ExistingCategories.Union(NewCategories).OrderBy(cID => mAllCategoriesOptions.FindIndex(ca => ca.Item1.CategoryID == cID));

        // Build DataTable and UniGrid structure
        foreach (int categoryId in combinedCategories)
        {
            var optionCategory = mAllCategoriesOptions.FirstOrDefault(k => k.Item1.CategoryID == categoryId);

            // Add columns to DataTable
            dt.Columns.Add(new DataColumn(categoryId.ToString(), typeof(String)));

            // Add column with option category live site display name to the grid with variant preview. In case live site display name is not available option category display name is used
            if (optionCategory != null)
            {
                AddGridColumn(ResHelper.LocalizeString(optionCategory.Item1.CategoryTitle), categoryId.ToString(), "#transform: ecommerce.skuoption.SKUName");
            }
        }

        // Add RowNumber column to DataTable
        dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
        AddGridColumn("RowNumber", "RowNumber", string.Empty, true);

        // Add Exist column to DataTable
        dt.Columns.Add(new DataColumn("Exist", typeof(bool)));

        // Add Variant number column to DataTable and UniGrid
        dt.Columns.Add(new DataColumn("VariantNumber", typeof(string)));
        AddGridColumn(GetString("com.sku.skunumber"), "VariantNumber");

        // Fill DataTable
        int index = 0;

        foreach (ProductVariant productVariant in productVariantList)
        {
            DataRow dr = dt.NewRow();

            int i = 0;
            foreach (int categoryId in productVariant.ProductAttributes.CategoryIDs)
            {
                // Fill values to dynamically added column
                var optionCategory = mAllCategoriesOptions.FirstOrDefault(k => k.Item1.CategoryID == categoryId);

                if (optionCategory != null)
                {
                    dr[optionCategory.Item1.CategoryID.ToString()] = productVariant.ProductAttributes[i].SKUID;
                    i++;
                }
            }

            dr["RowNumber"]     = index;
            dr["Exist"]         = productVariant.Existing;
            dr["VariantNumber"] = productVariant.Variant.SKUNumber;

            dt.Rows.Add(dr);
            index++;
        }

        ds.Tables.Add(dt);
        return(ds);
    }
Пример #12
0
 public Response Post([FromBody] NewCategories value)
 {
     return(repo.Create(value));
 }