Example #1
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Categories.CategoryId > 0)
            {
                repositoryData.UpdateCategory(Categories);
            }
            else
            {
                repositoryData.AddCategory(Categories);
            }

            int temp = repositoryData.Commit();

            if (temp > 0)
            {
                Message = "Category " + Categories.Name + " is saved successfully.";
            }
            else
            {
                Message = "Error occurs, pls try again later.";
            }
            return(RedirectToPage("Upsert", new { CategoryId = Categories.CategoryId }));
        }