Example #1
0
 public ActionResult AddTask(DoTask account)
 {
     if (ModelState.IsValid)
     {
         using (DbTasks dbt = new DbTasks())
         {
             dbt.TaskAccount.Add(account);
             dbt.SaveChanges();
         }
         ModelState.Clear();
         ViewBag.Message = "Succesfully added task.";
     }
     return(View());
 }
Example #2
0
        public ActionResult DeleteTask(FormCollection formCollection)
        {
            if (ModelState.IsValid)
            {
                using (DbTasks dbt = new DbTasks())
                {
                    string[] ids = formCollection["taskIdDelete"].Split(new char[] { ',' });
                    foreach (string id in ids)
                    {
                        var task = dbt.TaskAccount.Find(int.Parse(id));
                        dbt.TaskAccount.Remove(task);
                        dbt.SaveChanges();
                    }
                }
            }

            return(RedirectToAction("ViewTask"));
        }