示例#1
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            var user = await categoryService.GetById <MCategory>(_ID);

            if (ValidateChildren())
            {
                var request = new CategoryUpsertRequest
                {
                    Name = txtName.Text
                };

                await categoryService.Update <MCategory>(_ID, request);

                MessageBox.Show("Category have been updated successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                PanelHelper.SwapPanels(this.Parent, this, new CategoryList());
            }
        }
示例#2
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                try
                {
                    var request = new CategoryUpsertRequest
                    {
                        Name = txtName.Text
                    };

                    await categoryService.Insert <MCategory>(request);

                    MessageBox.Show("Category added Successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    PanelHelper.SwapPanels(this.Parent, this, new CourseAddSubcategory(_user, _course));
                }
                catch
                {
                    MessageBox.Show("You don't have permission to do that!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }