示例#1
0
        public categoryEdit(Category.Category category, adminPanel adminForm)
        {
            this.category   = category;
            this.adminPanel = adminForm;
            InitializeComponent();
            MaterialSkinManager materialUIManager = MaterialSkinManager.Instance;

            materialUIManager.AddFormToManage(this);
            materialUIManager.Theme = MaterialSkinManager.Themes.LIGHT;

            materialUIManager.ColorScheme = new ColorScheme(
                Primary.Blue400, Primary.Blue500,
                Primary.Blue500, Accent.Orange200,
                TextShade.WHITE
                );
            if (category.ID == 0)
            {
                idPlaceHolder.Text = "Nuova Categoria";
            }
            else
            {
                idPlaceHolder.Text = category.ID.ToString();
            }

            categoryName.Text = category.name;
        }
示例#2
0
        public void Save(Category.Category category)
        {
            using (_context)
            {
                using (var dbContextTransaction = _context.Database.BeginTransaction())
                {
                    try
                    {
                        var model = category.ToModel();

                        if (category.New)
                        {
                            _categories.Add(model);
                        }
                        else
                        {
                            _context.Entry(model).State = EntityState.Modified;
                        }

                        _context.SaveChanges();

                        dbContextTransaction.Commit();
                    }
                    catch (Exception)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
        }
示例#3
0
 public static CategoryModel ToModel(this Category.Category category)
 {
     return(new CategoryModel
     {
         BlogId = category.BlogId,
         Id = category.Id,
         Title = category.Title
     });
 }
示例#4
0
        //create category button
        private void createCategory_Click(object sender, EventArgs e)
        {
            Category.Category newCategory = new Category.Category();
            newCategory.ID   = 0;
            newCategory.name = "";
            categoryEdit editCategoryForm = new categoryEdit(newCategory, this);

            editCategoryForm.Show();
        }
示例#5
0
        public static Category.Category ToDomain(this CategoryModel model)
        {
            var category = new Category.Category();

            category.GetType().GetProperty("BlogId").SetValue(category, model.BlogId, null);
            category.GetType().GetProperty("Id").SetValue(category, model.Id, null);
            category.GetType().GetProperty("Title").SetValue(category, model.Title, null);

            return(category);
        }
        private void UpdateCategory(Category.Category category)
        {
            var i = Categories.FindFirstIndex(x => category.Id == x.Id);

            if (i < 0)
            {
                return;
            }

            Categories[i].Color       = category.Color;
            Categories[i].Description = category.Description;
            Categories[i].Image       = category.Image;
            Categories[i].Name        = category.Name;
            Categories[i].Id          = category.Id;
        }
示例#7
0
        public ICampaign Get(Category.Category category, double campaignValue, int minProductQuantity, CampaignTypes campaignTypes)
        {
            ICampaign campaign = null;

            switch (campaignTypes)
            {
            case CampaignTypes.Amount:
                campaign = new AmountCampaign(category, campaignValue, minProductQuantity);
                break;

            case CampaignTypes.Rate:
                campaign = new RateCampaign(category, campaignValue, minProductQuantity);
                break;
            }

            return(campaign);
        }
示例#8
0
        public override string ToString()
        {
            CategoryService      cats = new CategoryService();
            List <CategoryGroup> catg = cats.GetCategories();

            Category.Category cat = catg.Where(p => p.Categories.Count(q => q.Id == CategoryId) > 0).Select(p => p.Categories.Where(q => q.Id == CategoryId).First()).First();
            StringBuilder     s   = new StringBuilder();

            s.Append(User);
            s.AppendLine();
            s.Append(Location);
            s.AppendLine();
            s.AppendLine(cat.Name);
            s.Append(Parameters);
            s.AppendLine(Title);
            s.AppendLine(Body);
            s.Append(Price);

            return(s.ToString());
        }
示例#9
0
        //if id is 0 then i'm going to create a new category. if id != 0 then i update the selected category
        //called from categoryEdit form
        public bool updateCategory(Category.Category category)
        {
            bool result;

            if (category.ID != 0)
            {
                result = this.CategoryManager.updateCategory(this.loggedUser.email, this.loggedUser.password, category);
            }
            else
            {
                result = this.CategoryManager.createCategory(this.loggedUser.email, this.loggedUser.password, category);
            }
            if (result)
            {
                this.loadCategories();
            }
            else
            {
                MessageBox.Show("Errore all'aggiornameto/creazione della categoria");
            }
            return(result);
        }
示例#10
0
 public RateCampaign(Category.Category category, double campaignValue, int minProductQuantity)
 {
     _campaignValue      = campaignValue;
     _minProductQuantity = minProductQuantity;
     _category           = category;
 }
示例#11
0
        public void Category_ShouldArgumentNullException_WhenTitleIsNull(string title)
        {
            var category = new Category.Category(title);

            Assert.Throws <ArgumentNullException>(() => category.Title);
        }
示例#12
0
 public CampaignTest()
 {
     campaignFactory    = new CampaignFactory();
     electronicCategory = new Category.Category("Electronic");
 }