//Calendar public JsonResult GetTasks(ToDo_Task Meeting_Info) { string user_id_string = HttpContext.Session.GetString("User_ID"); int user_id; try { user_id = Convert.ToInt32(user_id_string); } catch { user_id = 0; } //var events = _context.Meeting_Info.Include("Meeting_Type").ToList(); //เลือกเฉพาะที่ยังไม่เสร็จ //var todoTask = _context.ToDo_Task.Where(i=>i.Task_isComplete != "Y" && i.Task_isFail != "Y").ToList(); var todoTask = _context.ToDo_Task.Where(i => i.User_ID == user_id && i.Task_Parent_ID == 0).ToList(); return(Json(todoTask)); }
public ActionResult Add([Bind("Task_ID, Task_Parent_ID, User_ID, Task_Name, Task_Due_Date, Task_Due_Time, Task_Description, Task_isFocus, Task_Create_Date, Task_Update_Date, Task_Status, Task_isComplete")] ToDo_Task ToDo_Task) { var returnData = "NOT"; string user_id_string = HttpContext.Session.GetString("User_ID"); int user_id; if (user_id_string == null) { TempData["msg"] = _CLSR.GetScriptAlertPopUp("Warning", "You have not login yet.", "", "D"); return(RedirectToAction("Index", "Home")); } else { try { user_id = Convert.ToInt32(user_id_string); } catch { user_id = 0; return(RedirectToAction("Index", "Home")); } String cDate = _CLSR.GetDateNow(""); String cTime = _CLSR.GetTimeNow(""); ToDo_Task.User_ID = user_id; ToDo_Task.Task_Create_Date = cDate; ToDo_Task.Task_Update_Date = cDate; ToDo_Task.Task_isComplete = "N"; ToDo_Task.Task_isFail = "N"; ToDo_Task.Task_Due_Date = _CLSR.ConvertDatePicker(ToDo_Task.Task_Due_Date); ToDo_Task.Task_Due_Time = _CLSR.ConvertTimePicker(ToDo_Task.Task_Due_Time, ":"); ToDo_Task.Task_isFocus = 0; ToDo_Task.Task_Status = "Y"; _CLSR.Exp_Up(user_id, 2); _context.Add(ToDo_Task); _context.SaveChanges(); returnData = "SUCCESS"; return(Json(returnData)); } }
//Checked Task public IActionResult Checked_Task(int id, [Bind("Task_ID, Task_Parent_ID, User_ID, Task_Name, Task_Due_Date, Task_Due_Time, Task_Description, Task_isFocus, Task_Create_Date, Task_Update_Date, Task_Status, Task_isComplete")] ToDo_Task ToDo_Task) { string user_id_string = HttpContext.Session.GetString("User_ID"); int user_id; if (user_id_string == null) { TempData["msg"] = _CLSR.GetScriptAlertPopUp("Warning", "You have not login yet.", "", "D"); return(RedirectToAction("Index", "Home")); } else { try { user_id = Convert.ToInt32(user_id_string); } catch { user_id = 0; return(RedirectToAction("Index", "Home")); } var todo_task = _context.ToDo_Task.Where(i => i.Task_ID == id).FirstOrDefault(); String cDate = _CLSR.GetDateNow(""); String cTime = _CLSR.GetTimeNow(""); todo_task.Task_isComplete = "Y"; _CLSR.Exp_Up(user_id, 10); _context.Update(todo_task); _context.SaveChanges(); return(RedirectToAction("Add_Task", "Todo_Task")); } }