public ActionResult updateTaskUser(int taskId, string status) { bool finished; try { var task = db.tasks.Where(e => e.taskId == taskId).First(); task.status = status; db.Entry(task).State = EntityState.Modified; db.SaveChanges(); tasklog log = new tasklog(); log.taskId = task.taskId; log.date = DateTime.Now; if (task.status != "Pending") { log.logcontent = "canceled the submission"; finished = false; } else { log.logcontent = "finished the task"; finished = true; } log.assignto = task.assignto; db.tasklogs.Add(log); db.SaveChanges(); projectactivity pact = new projectactivity(); pact.projId = task.projId; pact.taskId = task.taskId; pact.status = task.status; pact.assignto = task.assignto; pact.datetime = DateTime.Now; if (finished) { pact.logContent = "finished the task."; } else { pact.logContent = "canceled the submission."; } db.projectactivities.Add(pact); db.SaveChanges(); updateLastActDate(task.projId); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public ActionResult addTask(task task) { try { DateTime date = DateTime.Now; task.status = "Available"; task.startdate = date; db.tasks.Add(task); db.SaveChanges(); for (int i = 0; i < 2; i++) { DateTime date2 = DateTime.Now; tasklog log = new tasklog(); log.taskId = task.taskId; if (i == 0) { log.logcontent = "created the task"; } else { log.logcontent = "assigned task to"; } log.date = date2; log.assignto = task.assignto; db.tasklogs.Add(log); db.SaveChanges(); } projectactivity pact = new projectactivity(); pact.projId = task.projId; pact.taskId = task.taskId; pact.status = task.status; pact.assignto = task.assignto; pact.datetime = date; pact.logContent = "created a task and assign to"; db.projectactivities.Add(pact); db.SaveChanges(); updateLastActDate(task.projId); return(Json("Success", JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json("Failed", JsonRequestBehavior.AllowGet)); } }
private tasklog checkChanged(task task) { var oldtask = db.tasks.Where(e => e.taskId == task.taskId).First(); tasklog log = new tasklog(); projectactivity pact = new projectactivity(); pact.projId = oldtask.projId; pact.taskId = oldtask.taskId; pact.assignto = oldtask.assignto; pact.datetime = DateTime.Now; if (task.status == "Completed") { log.logcontent = "approved the submission"; pact.logContent = "approved the submission of"; pact.status = task.status; } else if (task.status == "Return") { task.status = "Available"; log.logcontent = "returned your task"; pact.logContent = "returned the task of"; pact.status = task.status; } else if (task.assignto != oldtask.assignto) { log.logcontent = "assigned task to"; pact.logContent = "assigned task to"; pact.status = task.status; } else { log.logcontent = "assigned task to"; pact.logContent = "assigned task to"; pact.status = task.status; } db.projectactivities.Add(pact); db.SaveChanges(); return(log); }