public ActionResult DisjointTask(string id, OtherTaskModel task) { assignees.Remove(Session["UserId"].ToString()); Session["JoinedTaskCount"] = Int32.Parse(Session["JoinedTaskCount"].ToString()) - 1; if (assignees.Count == 0 || assignees == null) { task.assignees = assignees; var filter = Builders <OtherTaskModel> .Filter.Eq("_id", ObjectId.Parse(id)); var update = Builders <OtherTaskModel> .Update .Set("assignees", assignees) .Set("state", "Unassigned"); var result = productCollection.UpdateOne(filter, update); assignees = new List <string>(); return(RedirectToAction("Details", new { id = id })); } else { task.assignees = assignees; var filter = Builders <OtherTaskModel> .Filter.Eq("_id", ObjectId.Parse(id)); var update = Builders <OtherTaskModel> .Update .Set("assignees", assignees); var result = productCollection.UpdateOne(filter, update); assignees = new List <string>(); return(RedirectToAction("Details", new { id = id })); } }
public ActionResult DeleteComment(string id, OtherTaskModel task, string comment) { OtherTaskModel.Comment comment1 = new OtherTaskModel.Comment(); var singletask = productCollection.AsQueryable <OtherTaskModel>().SingleOrDefault(x => x.Id == new ObjectId(id)); foreach (var coment in singletask.Comments) { if (coment.commId == comment) { comment1 = coment; // Debug.WriteLine(comment); } } //Debug.WriteLine(comment); comments.RemoveAll(l => l.commId == comment); // Debug.WriteLine(comments.Count()); //Debug.WriteLine(comment1.comm); var filter = Builders <OtherTaskModel> .Filter.Eq("_id", ObjectId.Parse(id)); var update = Builders <OtherTaskModel> .Update .Set("Comments", comments); var result = productCollection.UpdateOne(filter, update); return(RedirectToAction("AddComment", new { id = id })); }
public ActionResult Edit(string id, OtherTaskModel task) { task.TaskRequirements = taskSpecList; //task.posterName = "Nicole Garrow"; try { var filter = Builders <OtherTaskModel> .Filter.Eq("_id", ObjectId.Parse(id)); var update = Builders <OtherTaskModel> .Update .Set("requester", task.requester) .Set("ImportanceLevel", task.ImportanceLevel) .Set("posterName", task.posterName) .Set("taskTitle", task.taskTitle) .Set("TaskRequirements", task.TaskRequirements) .Set("AdditionalInfo", task.AdditionalInfo) .Set("assignees", task.assignees) .Set("state", task.state); var result = productCollection.UpdateOne(filter, update); deletedTask = new List <object>(); task.Id = ObjectId.Parse(id); deletedTask.Add(task); taskSpecList = new List <OtherTaskModel.TaskRequirement>(); return(RedirectToAction("Details", new { id = id })); } catch { return(View()); } }
public ActionResult JoinTask(string id, OtherTaskModel task) { assignees.Add(Session["UserId"].ToString()); task.assignees = assignees; var filter = Builders <OtherTaskModel> .Filter.Eq("_id", ObjectId.Parse(id)); var update = Builders <OtherTaskModel> .Update .Set("assignees", assignees) .Set("state", "Assigned"); var result = productCollection.UpdateOne(filter, update); assignees = new List <string>(); Session["JoinedTaskCount"] = Int32.Parse(Session["JoinedTaskCount"].ToString()) + 1; return(RedirectToAction("Details", new { id = id })); }
public ActionResult AddComment(string id, OtherTaskModel task) { scomm.volunteerId = Session["UserId"].ToString(); scomm.comm = task.singleComm; scomm.volunteerName = Session["Username"].ToString(); scomm.volunteerPhoto = Session["Img"].ToString(); comments = new List <OtherTaskModel.Comment>(); var singletask = productCollection.AsQueryable <OtherTaskModel>().SingleOrDefault(x => x.Id == new ObjectId(id)); if (singletask.Comments == null || singletask.Comments.Count() == 0) { comments = new List <OtherTaskModel.Comment>(); scomm.commId = "1"; } else { List <int> ids = new List <int>(); foreach (var coment in singletask.Comments) { comments.Add(coment); ids.Add(Int32.Parse(coment.commId)); } scomm.commId = (ids.Max() + 1).ToString(); } comments.Add(scomm); // task.singleComm = ""; var filter = Builders <OtherTaskModel> .Filter.Eq("_id", ObjectId.Parse(id)); var update = Builders <OtherTaskModel> .Update .Set("Comments", comments) .Set("singleComm", ""); var result = productCollection.UpdateOne(filter, update); return(RedirectToAction("AddComment", new { id = id })); //return RedirectToAction("Details", new { id = id }); }
public ActionResult CompleteTask(string id, OtherTaskModel task) { var filter = Builders <OtherTaskModel> .Filter.Eq("_id", ObjectId.Parse(id)); var update = Builders <OtherTaskModel> .Update .Set("state", "Completed"); var result = productCollection.UpdateOne(filter, update); if (Session["Role"].ToString() == "Admin" || Session["Role"].ToString() == "Moderator") { Session["TaskCount"] = Int32.Parse(Session["TaskCount"].ToString()) - 1; // Session["JoinedTaskCount"] = Int32.Parse(Session["JoinedTaskCount"].ToString()) - 1; Session["CompletedTaskCount"] = Int32.Parse(Session["CompletedTaskCount"].ToString()) + 1; return(RedirectToAction("../CompletedTasks/Index")); } else { return(RedirectToAction("../AllTasks/Index")); } }
private List <OtherTaskModel> ConvertOtherProjectTasksDataTableToList(DataTable dt) { List <OtherTaskModel> result = new List <OtherTaskModel>(); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { OtherTaskModel obj = new OtherTaskModel(); obj.OtherTaskId = Convert.ToInt32(dt.Rows[i]["OtherTaskId"]); obj.TotalCount = Convert.ToInt32(dt.Rows[i]["TotalCount"]); obj.OtherTaskType = dt.Rows[i]["CategoryName"].ToString(); obj.OtherTaskTypeId = Convert.ToInt32(dt.Rows[i]["OtheryTaskTypeId"]); obj.AssignedUserId = Convert.ToInt32(dt.Rows[i]["AssignedUserId"]); obj.TaskName = dt.Rows[i]["TaskName"].ToString(); obj.ExpectedStartDate = Convert.ToDateTime(dt.Rows[i]["ExpectedStartDate"]).ToString("yyyy-MM-dd HH:mm"); obj.ExpectedEndDate = Convert.ToDateTime(dt.Rows[i]["ExpectedEndDate"]).ToString("yyyy-MM-dd HH:mm"); result.Add(obj); } } return(result); }
public ActionResult Create(OtherTaskModel otherTask) { otherTask.posterName = Session["Username"].ToString(); otherTask.posterPhoto = Session["Img"].ToString(); otherTask.TaskRequirements = taskSpecList; otherTask.state = "Unassigned"; otherTask.posterPhoto = Session["Img"].ToString(); var vol = volunteerCollection.AsQueryable <VolunteerModel>().SingleOrDefault(x => x.Name == otherTask.requester); otherTask.reqPhoto = vol.UserPhoto; try { productCollection.InsertOne(otherTask); taskSpecList = new List <OtherTaskModel.TaskRequirement>(); deletedTask = new List <object>(); deletedTask.Add(otherTask); Session["TaskCount"] = Int32.Parse(Session["TaskCount"].ToString()) + 1; return(RedirectToAction("Details", new { id = otherTask.Id })); } catch { return(View()); } }