protected void Page_Load(object sender, EventArgs e)
        {
            int categoryId;

            if (!int.TryParse(this.RouteData.Values["id"].ToString(), out categoryId))
            {
                ErrorSuccessNotifier.AddErrorMessage("Missing category id or category id is not a number");
                return;
            }

            Category category = this.data.Categories.GetById(categoryId);

            if (category == null)
            {
                ErrorSuccessNotifier.AddErrorMessage("Worng category id!");
                return;
            }

            this.category = category;
        }
        public void FormViewCategory_InsertItem()
        {
            var category = new Category();
            this.TryUpdateModel(category);

            if (!this.ModelState.IsValid)
            {
                this.SetFormValidity(false);
                this.DisplayErrorMessage();
                return;
            }
            else
            {
                this.SetFormValidity(true);
            }

            this.data.Categories.Add(category);
            this.data.SaveChanges();
            this.CloseForm();
            ErrorSuccessNotifier.AddSuccessMessage(MessageCategoryCreated);
        }