コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        private void CategoryButton_Click(object sender, EventArgs e)
        {
            CategoryForm categoryForm = new CategoryForm();

            categoryForm.Show();
            this.Hide();
        }
コード例 #6
0
        private void BtnCategoryAdd_Click(object sender, RoutedEventArgs e)
        {
            CategoryForm frmCategory = new CategoryForm(true);

            this.Hide();
            frmCategory.ShowDialog();
            this.Show();
        }
コード例 #7
0
ファイル: Home.cs プロジェクト: detroitcoder1/Desktop-App-WPF
        private void btnAdd_Click(object sender, EventArgs e)

        {
            this.Visible = false;
            CategoryForm form = new CategoryForm();

            form.Show();
        }
コード例 #8
0
 private void buttonGoCategories_Click(object sender, EventArgs e)
 {
     if (Application.OpenForms["CategoryOperations"] == null)
     {
         Form CategoryOperations = new CategoryForm();
         CategoryOperations.Show();
     }
 }
コード例 #9
0
        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();
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: Alihaydar92/cafe-desktop
        private void menu_strip_add_category_Click(object sender, EventArgs e)
        {
            CategoryForm form_Category = new CategoryForm();

            form_Category.ShowDialog();
            categoryListOnInterface();
            tableListOnInterface();
            foodStuffListOnInterface();
        }
コード例 #11
0
        private void OnAddClick(object sender, EventArgs e)
        {
            Category obj = new Category();

            if (CategoryForm.ShowForm(obj))
            {
                this.LoadListData(obj);
            }
        }
コード例 #12
0
        private void categoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CategoryForm category = new CategoryForm
            {
                userID = userId
            };

            category.Show();
        }
コード例 #13
0
        private void BtnCateg_Click(object sender, EventArgs e)
        {
            panel3.Controls.Clear();
            CategoryForm categoryForm = new CategoryForm();

            categoryForm.TopLevel = false;
            panel3.Controls.Add(categoryForm);
            categoryForm.Show();
        }
コード例 #14
0
ファイル: CategoryCommands.cs プロジェクト: anoozz/nbooks
        public override void Run()
        {
            CategoryForm form = new CategoryForm(category);

            form.CategorySave += delegate(Category sender, EventArgs e) {
                form.Category.SaveOrUpdate();
                form.Close();
            };
            WorkbenchSingleton.AddChild(form);
        }
コード例 #15
0
        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));
        }
コード例 #16
0
        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));
        }
コード例 #17
0
        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"));
        }
コード例 #18
0
ファイル: MainForm.cs プロジェクト: Mortality9099/Shop
 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);
 }
コード例 #19
0
        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"));
        }
コード例 #20
0
        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));
        }
コード例 #21
0
        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));
        }
コード例 #22
0
        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));
        }
コード例 #23
0
        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));
        }
コード例 #24
0
ファイル: InvictusLoginForm.cs プロジェクト: binknam/Invictus
 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();
         }
     }
 }
コード例 #25
0
        private void OnOpenClick(object sender, EventArgs e)
        {
            Category obj = this.GetSelected();

            if (obj != null)
            {
                obj.RefershData();
            }

            if (CategoryForm.ShowForm(obj))
            {
                this.LoadListData(obj);
            }
        }
コード例 #26
0
        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);
        }
コード例 #27
0
        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));
        }
コード例 #28
0
 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;
         }
     }
 }
コード例 #29
0
        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"));
        }
コード例 #30
0
 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
             };
         }
     }
 }
コード例 #31
0
    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();
    }
コード例 #32
0
    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();
    }