Esempio n. 1
0
 public ActionResult Edit(int id)
 {
     using (bewaretaskaspEntities3 database = new bewaretaskaspEntities3())
     {
         var data = database.tasks.Where(c => c.id == id).First();
         ViewData["editID"] = data;
     }
     return(View());
 }
Esempio n. 2
0
        public ActionResult EditTask(task task)
        {
            using (bewaretaskaspEntities3 database = new bewaretaskaspEntities3())
            {
                var data = database.tasks.Where(c => c.id == task.id).First();

                data.TaskName = task.TaskName;
                data.deadline = task.deadline;
                database.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 3
0
 public ActionResult DeleteTask(int id)
 {
     if (ModelState.IsValid)
     {
         using (bewaretaskaspEntities3 database = new bewaretaskaspEntities3())
         {
             var data = database.tasks.Where(c => c.id == id).First();
             database.tasks.Remove(data);
             database.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 4
0
 public ActionResult CreateTask(task task)
 {
     if (ModelState.IsValid)
     {
         using (bewaretaskaspEntities3 database = new bewaretaskaspEntities3())
         {
             int uid = Convert.ToInt32(Session["userID"]);
             task.idUser = uid;
             database.tasks.Add(task);
             database.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 5
0
 // GET: Task
 public ActionResult Index()
 {
     if (ModelState.IsValid)
     {
         using (bewaretaskaspEntities3 database = new bewaretaskaspEntities3())
         {
             int uid  = Convert.ToInt32(Session["userID"]);
             var data = database.tasks.Where(c => c.idUser == uid).ToList();
             if (data.Count() > 0)
             {
                 string result = "";
                 int    x      = 1;
                 foreach (var a in data)
                 {
                     result += "<tr>" +
                               "<td>" + (x++).ToString() + "</td>" +
                               "<td>" + a.TaskName + "</td>";
                     if (a.deadline.Year == 1)
                     {
                         result +=
                             "<td>" + "-" + "</td>";
                     }
                     else
                     {
                         result +=
                             "<td>" + a.deadline + "</td>";
                     }
                     result += "<td>" + "Edit  |   Delete" + "</td>" +
                               "</tr>";
                 }
                 ViewData["task"]     = result;
                 ViewData["taskList"] = data;
                 return(View());
             }
             else
             {
                 return(View());
             }
         }
     }
     return(View());
 }
Esempio n. 6
0
 public ActionResult Login(string email, string password)
 {
     if (ModelState.IsValid)
     {
         using (bewaretaskaspEntities3 database = new bewaretaskaspEntities3())
         {
             var data = database.users.Where(s => s.email.Equals(email) && s.password.Equals(password)).ToList();
             if (data.Count() > 0)
             {
                 //add session
                 Session["email"]  = data.FirstOrDefault().email;
                 Session["userID"] = data.FirstOrDefault().id;
                 return(RedirectToAction("Index", "Task", new { area = "" }));
             }
             else
             {
                 ViewBag.error = "Login failed";
                 return(RedirectToAction("Login", "Home", new { area = "" }));
             }
         }
     }
     return(View());
 }
Esempio n. 7
0
 public ActionResult CreateUser(user usr)
 {
     if (ModelState.IsValid)
     {
         using (bewaretaskaspEntities3 database = new bewaretaskaspEntities3())
         {
             var check = database.users.FirstOrDefault(s => s.email == usr.email);
             if (check == null)
             {
                 database.Configuration.ValidateOnSaveEnabled = false;
                 database.users.Add(usr);
                 database.SaveChanges();
                 return(RedirectToAction("Login", "Home", new { area = "" }));
             }
             else
             {
                 ViewBag.error = "Email already exists";
                 return(RedirectToAction("Register", "Home", new { area = "" }));
             }
         }
     }
     return(RedirectToAction("Register", "Home", new { area = "" }));
 }