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; }
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(); } } } }
public static CategoryModel ToModel(this Category.Category category) { return(new CategoryModel { BlogId = category.BlogId, Id = category.Id, Title = category.Title }); }
//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(); }
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; }
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); }
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()); }
//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); }
public RateCampaign(Category.Category category, double campaignValue, int minProductQuantity) { _campaignValue = campaignValue; _minProductQuantity = minProductQuantity; _category = category; }
public void Category_ShouldArgumentNullException_WhenTitleIsNull(string title) { var category = new Category.Category(title); Assert.Throws <ArgumentNullException>(() => category.Title); }
public CampaignTest() { campaignFactory = new CampaignFactory(); electronicCategory = new Category.Category("Electronic"); }