public IActionResult New(AddNewCategoryBindingModel model, HttpResponse response, HttpSession session)
 {
     if (Data.Data.Contex.Sessions.First(x => x.SessionId == session.Id).User.IsAdmin)
     {
         var service = new CategoryService();
         service.AddNewCategory(model);
     }
     Redirect(response, "/home/indexlogged");
     return(null);
 }
Esempio n. 2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            var category = new Category
            {
                Name  = txtName.Text,
                Title = txtTitle.Text
            };

            CategoryService.AddNewCategory(category);
            UoW.SaveAllChanges();
            Response.Redirect("~/Default.aspx");
        }
Esempio n. 3
0
 public ActionResult Create([Bind(Include = "CategoryName,Description")] CategoryModel Category)
 {
     if (ModelState.IsValid)
     {
         if (string.IsNullOrEmpty(Category.CategoryName) == false && string.IsNullOrEmpty(Category.Description) == false)
         {
             CategoryService catService = new CategoryService();
             int             result     = catService.AddNewCategory(Category.CategoryName, Category.Description);
             if (result > 0)
             {
                 return(Content("<script>parent.jQuery.fancybox.close();</script>"));
             }
         }
     }
     return(View(Category));
 }
Esempio n. 4
0
 private void addCategoryButton_Click(object sender, EventArgs e)
 {
     if (categoryNameTextBox.Text == "")
     {
         MessageBox.Show("Name box has to be filled");
     }
     else
     {
         CategoryService categoryService = new CategoryService();
         int             result          = categoryService.AddNewCategory(categoryNameTextBox.Text);
         if (result > 0)
         {
             MessageBox.Show("Category added successfully");
         }
         else
         {
             MessageBox.Show("Error in adding category");
         }
     }
 }
Esempio n. 5
0
 public void Post([FromBody] CategoryDto value)
 {
     cs.AddNewCategory(value);
 }