Exemple #1
0
 public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid) //checking model is valid or not
     {
         categorymodels.Edit(category);
         List<Category> model = new List<Category>();
         model = categorymodels.SelectAll();
         return View("List", model);
     }
     return View(category);
 }
Exemple #2
0
        public ActionResult Add(Category category)
        {
            if (ModelState.IsValid) //checking model is valid or not
            {
                bool result = categorymodels.Add(category);
                if (result)
                {
                    List<Category> model = new List<Category>();
                    model = categorymodels.SelectAll();
                    return View("List", model);
                }
            }

            return View(category);
        }
Exemple #3
0
 public bool Edit(Category category)
 {
     SqlConnection con = null;
     bool result = false;
     try
     {
         con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
         SqlCommand cmd = new SqlCommand();
         cmd.CommandText = "Update Category set name_category='" + category.C_Name + "' + description_category='" + category.C_desc + "';
         cmd.Connection = con;
         cmd.CommandType = CommandType.Text;
         con.Open();
         cmd.ExecuteNonQuery();
         return result = true;
     }
     catch (Exception ex)
     {
         return result = false;
     }
     finally
     {
         con.Close();
     }
 }
Exemple #4
0
 public bool Add(Category category)
 {
     SqlConnection con = null;
     bool result = false;
     try
     {
         con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
         SqlCommand cmd = new SqlCommand();
         cmd.CommandText = "Insert into Category(name_Category,description_Category) values ('" + category.C_Name + category.C_desc+"')";
         cmd.Connection = con;
         cmd.CommandType = CommandType.Text;
         con.Open();
         cmd.ExecuteNonQuery();
         return result = true;
     }
     catch (Exception ex)
     {
         return result = false;
     }
     finally
     {
         con.Close();
     }
 }
Exemple #5
0
 public ActionResult Edit(int Id = 0)
 {
     Category category = new Category();
     category = categorymodels.SelectById(Id);
     return View("Edit", category);
 }
Exemple #6
0
 public ActionResult Add()
 {
     Category model = new Category();
     return View(model);
 }