public async Task <IActionResult> Put(long id, CategoryForm model) { if (ModelState.IsValid) { var category = await _categoryRepository.Query().FirstOrDefaultAsync(x => x.Id == id); if (category == null) { return(NotFound()); } category.Name = model.Name; category.SeoTitle = model.Slug; category.Description = model.Description; category.DisplayOrder = model.DisplayOrder; category.ParentId = model.ParentId; category.IncludeInMenu = model.IncludeInMenu; category.IsPublished = model.IsPublished; await SaveCategoryImage(category, model); await _categoryService.Update(category); return(Accepted()); } return(BadRequest(ModelState)); }
public async Task <IActionResult> Post(CategoryForm model) { if (ModelState.IsValid) { var category = new Category { Name = model.Name, Slug = model.Slug, MetaTitle = model.MetaTitle, MetaKeywords = model.MetaKeywords, MetaDescription = model.MetaDescription, DisplayOrder = model.DisplayOrder, Description = model.Description, ParentId = model.ParentId, IncludeInMenu = model.IncludeInMenu, IsPublished = model.IsPublished }; await SaveCategoryImage(category, model); await _categoryService.Create(category); return(CreatedAtAction(nameof(Get), new { id = category.Id }, null)); } return(BadRequest(ModelState)); }
public async Task <ApiError> OnCategoryCreate(CategoryForm form) { if (form == null) { return new ApiError { Message = "Something went wrong." } } ; var result = await _categoriesService.CreateCategory(form); if (result.Response != null) { Categories.Add(result.Response); StateHasChanged(); } if (result.Error != null) { return(result.Error); } return(null); }
public async Task <IActionResult> Put(long id, CategoryForm model) { if (ModelState.IsValid) { var category = await _categoryRepository.Query().FirstOrDefaultAsync(x => x.Id == id); if (category == null) { return(NotFound()); } category.Name = model.Name; category.SeoTitle = model.Slug; category.Description = model.Description; category.DisplayOrder = model.DisplayOrder; category.ParentId = model.ParentId; category.IncludeInMenu = model.IncludeInMenu; category.IsPublished = model.IsPublished; if (category.ParentId.HasValue && await HaveCircularNesting(category.Id, category.ParentId.Value)) { ModelState.AddModelError("ParentId", "Parent category cannot be itself children"); return(BadRequest(ModelState)); } await SaveCategoryImage(category, model); await _categoryService.Update(category); return(Accepted()); } return(BadRequest(ModelState)); }
private void CategoryButton_Click(object sender, EventArgs e) { CategoryForm categoryForm = new CategoryForm(); categoryForm.Show(); this.Hide(); }
private void BtnCategoryAdd_Click(object sender, RoutedEventArgs e) { CategoryForm frmCategory = new CategoryForm(true); this.Hide(); frmCategory.ShowDialog(); this.Show(); }
private void btnAdd_Click(object sender, EventArgs e) { this.Visible = false; CategoryForm form = new CategoryForm(); form.Show(); }
private void buttonGoCategories_Click(object sender, EventArgs e) { if (Application.OpenForms["CategoryOperations"] == null) { Form CategoryOperations = new CategoryForm(); CategoryOperations.Show(); } }
private void categoryToolStripMenuItem_Click(object sender, EventArgs e) { CategoryForm childForm = new CategoryForm(FinviewContainer.Instance.Resolve <ICategoryService>()); childForm.MdiParent = this; childForm.WindowState = FormWindowState.Maximized; childForm.Show(); }
private void menu_strip_add_category_Click(object sender, EventArgs e) { CategoryForm form_Category = new CategoryForm(); form_Category.ShowDialog(); categoryListOnInterface(); tableListOnInterface(); foodStuffListOnInterface(); }
private void OnAddClick(object sender, EventArgs e) { Category obj = new Category(); if (CategoryForm.ShowForm(obj)) { this.LoadListData(obj); } }
private void categoryToolStripMenuItem_Click(object sender, EventArgs e) { CategoryForm category = new CategoryForm { userID = userId }; category.Show(); }
private void BtnCateg_Click(object sender, EventArgs e) { panel3.Controls.Clear(); CategoryForm categoryForm = new CategoryForm(); categoryForm.TopLevel = false; panel3.Controls.Add(categoryForm); categoryForm.Show(); }
public override void Run() { CategoryForm form = new CategoryForm(category); form.CategorySave += delegate(Category sender, EventArgs e) { form.Category.SaveOrUpdate(); form.Close(); }; WorkbenchSingleton.AddChild(form); }
public async Task <IActionResult> Post([FromForm] CategoryForm newCategory, string budgetId) { var modifiedBudget = await _categoryProcessor.AddCategoryToBudget(newCategory, budgetId); if (modifiedBudget == null) { return(NotFound()); } return(Ok(modifiedBudget)); }
public async Task <IActionResult> Edit([FromForm] CategoryForm category, string budgetId) { var modifiedBudget = await _categoryProcessor.EditCategory(category, budgetId); if (modifiedBudget == null) { return(NotFound()); } return(Ok(modifiedBudget)); }
public ActionResult Create(CategoryForm categoryForm) { Category category = new Category(); category.CategoryName = categoryForm.CategoryName; category.Description = categoryForm.Description; db.Categories.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); }
private void btnCategory_Click(object sender, EventArgs e) { HideOtherForm("FrmCategory"); if (IsAlreadyOpened("FrmCategory")) { return; } CategoryForm.MdiParent = this; CategoryForm.Show(); CategoryForm.Location = new Point(200, 20); }
public ActionResult Update(CategoryForm categoryForm) { Category category = new Category(); category.CategoryID = categoryForm.CategoryID; category.CategoryName = categoryForm.CategoryName; category.Description = categoryForm.Description; db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <Budget> EditCategory(CategoryForm categoryForm, string budgetId) { var category = new Category { Id = new ObjectId(categoryForm.Id), Name = categoryForm.Name, Description = categoryForm.Description, IsExpense = true }; return(await _budgetRepository.EditCategory(new ObjectId(budgetId), category)); }
public async Task <Budget> AddCategoryToBudget(CategoryForm categoryForm, string budgetId) { var category = new Category { Name = categoryForm.Name, Description = categoryForm.Description, IsExpense = true, PlannedTransactions = new List <Transaction>(), ActualTransactions = new List <Transaction>() }; return(await _budgetRepository.AddCategory(new ObjectId(budgetId), category)); }
public async Task <IActionResult> CreateCategoryAsync( [FromBody] CategoryForm form, CancellationToken ct) { if (!ModelState.IsValid) { return(BadRequest(new ApiError(ModelState))); } var category = await _repository.CreateCategoryAsync(form, ct); return(Ok(category)); }
public IActionResult Get(long id) { var category = _categoryRepository.Query().FirstOrDefault(x => x.Id == id); var model = new CategoryForm { Id = category.Id, Name = category.Name, ParentId = category.ParentId, IsPublished = category.IsPublished }; return(Json(model)); }
private void loginBtn_Click(object sender, EventArgs e) { if (usernamTxt.Text != "" && passwordTxt.Text != "") { user = loginController.invictusUserRepository.findById(user.Username); if (user.Password != null && user.Password == passwordTxt.Text) { CategoryForm categoryForm = new CategoryForm(); categoryForm.setCurrentUser(user); categoryForm.Show(); Hide(); } } }
private void OnOpenClick(object sender, EventArgs e) { Category obj = this.GetSelected(); if (obj != null) { obj.RefershData(); } if (CategoryForm.ShowForm(obj)) { this.LoadListData(obj); } }
public CategoryForm GenerateCategoryForm(Category category) { var categoryForm = new CategoryForm(); categoryForm.Id = category.Id.ToString(); categoryForm.Name = category.Name; categoryForm.Description = category.Description; categoryForm.AmountBudgeted = CalulateAmountBudgeted(category); categoryForm.AmountSpent = CalulateAmountSpent(category); categoryForm.AmountRemaining = categoryForm.AmountBudgeted - categoryForm.AmountSpent; categoryForm.ProjectedRemaining = CalculateCategoryProjection(category); categoryForm.PlannedTransactions = GenerateTransactionForms(category.PlannedTransactions, IsPlanned: true); categoryForm.ActualTransactions = GenerateTransactionForms(category.ActualTransactions, IsPlanned: false); return(categoryForm); }
public IActionResult Get(long id) { var category = _categoryRepository.Query().Include(x => x.ThumbnailImage).FirstOrDefault(x => x.Id == id); var model = new CategoryForm { Id = category.Id, Name = category.Name, Description = category.Description, ParentId = category.ParentId, IsPublished = category.IsPublished, ThumbnailImageUrl = _mediaService.GetThumbnailUrl(category.ThumbnailImage), }; return(Json(model)); }
private void ButtonClick(object sender, EventArgs e) { using (var dialog = new CategoryForm()) { if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Selections.Add(dialog.Item); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } } }
public IActionResult EditCategoryPost(CategoryForm categoryForm) { _logger.LogInformation($"=== EditCategoryPost({categoryForm}) ==="); var oldAssociations = _dbContext.Associations.Where(x => x.CategoryId == categoryForm.CategoryId); _dbContext.Associations.RemoveRange(oldAssociations); foreach (int productId in categoryForm.ProductIds) { Association newAssociation = new Association(); newAssociation.ProductId = productId; newAssociation.CategoryId = categoryForm.CategoryId; _dbContext.Associations.Add(newAssociation); } _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
private void SaveCategoryImage(Category category, CategoryForm model) { if (model.ThumbnailImage != null) { var fileName = SaveFile(model.ThumbnailImage); if (category.ThumbnailImage != null) { category.ThumbnailImage.FileName = fileName; } else { category.ThumbnailImage = new Media { FileName = fileName }; } } }
private void listCategories_MouseDoubleClick(object sender, MouseEventArgs e) { // get the category. var category = GetSelectedCategory(); if (null == category) { return; } // make a new category. var categoryForm = new CategoryForm(_engine, GetSelectedCategory() ); // load the dialog box. if (categoryForm.ShowDialog() != DialogResult.OK) { return; } // reload all the categories. _categories.ReloadCategories(); // reload everything ReloadCategories(); }
private void Edit_Click(object sender, EventArgs e) { // make a new category. var category = new CategoryForm(_engine, GetSelectedCategory()); // load the dialog box. if (category.ShowDialog() != DialogResult.OK) { return; } // reload all the categories. _categories.ReloadCategories(); // reload everything ReloadCategories(); }