public PartialViewResult Create()
        {
            var _project = mongoDatabase.GetCollection<Project>("Project");
            var _employee = mongoDatabase.GetCollection<Employee>("Employee");

            IList<Project> listProject = new List<Project>();
            var getAllProjects = _project.FindAs(typeof(Project), Query.NE("Name", "null"));
            foreach (Project proj in getAllProjects)
            {
                listProject.Add(proj);
            }
            var selectProj = new SelectList(listProject, "ProjectId", "Name", listProject[0].ProjectId);
            ViewData["Project"] = selectProj;

            IList<Employee> listEmployee = new List<Employee>();
            var getAllEmployees = _employee.FindAs(typeof(Employee), Query.NE("IsActive", false));
            foreach (Employee emp in getAllEmployees)
            {
                listEmployee.Add(emp);
            }
            var selectEmp = new SelectList(listEmployee, "EmpId", "FullName", 1);
            ViewData["Employee"] = selectEmp;

            List<Status> listStatus = new List<Status>();

            Status stT3 = new Status() { Name = "Not Started" };
            listStatus.Add(stT3);
            Status stT1 = new Status() { Name = "In-Process" };
            listStatus.Add(stT1);
            Status stT2 = new Status() { Name = "Complete" };
            listStatus.Add(stT2);
            Status stT5 = new Status() { Name = "Waiting Approval" };
            listStatus.Add(stT5);
            Status stT6 = new Status() { Name = "On Hold" };
            listStatus.Add(stT6);
            Status stT4 = new Status() { Name = "Cancelled" };
            listStatus.Add(stT4);

            var selectSt = new SelectList(listStatus, "Name", "Name", listStatus[0].Name);
            ViewData["Status"] = selectSt;

            List<Status> listPriority = new List<Status>();

            Status stP3 = new Status() { Name = "Very Urgent" };
            listPriority.Add(stP3);
            Status stP1 = new Status() { Name = "Urgent" };
            listPriority.Add(stP1);
            Status stP2 = new Status() { Name = "Normal" };
            listPriority.Add(stP2);

            var selectPriority = new SelectList(listPriority, "Name", "Name", listPriority[0].Name);
            ViewData["Priority"] = selectPriority;

            return PartialView();
        }
        public PartialViewResult Monitor(string Id)
        {

            var _task = mongoDatabase.GetCollection<Task>("Task");
            var _employee = mongoDatabase.GetCollection<Employee>("Employee");
            var _monitor = mongoDatabase.GetCollection<DevBase>("DevBase");

            var getBase = _monitor.FindAs(typeof(DevBase), Query.EQ("TaskId", Id));

            if (getBase.Count() > 0)
            {
                foreach (DevBase mon in getBase)
                {
                    if (mon.EmpId.Equals(Id) && mon != null)
                    {
                        return EditMonitor(mon.Id.ToString());
                    }
                }
            }

            ObjectId taskId;
            var isValid = ObjectId.TryParse(Id, out taskId);
            string EmpId = "";
            if (isValid)
            {
                var getQuery = Query<Task>.EQ(e => e.TaskId, taskId);
                IList<Task> listTask = new List<Task>();
                var tsk = _task.FindOne(getQuery);
                EmpId = tsk.AssignedTo[0].EmpId.ToString();
                listTask.Add(tsk);
                var selectTask = new SelectList(listTask, "TaskId", "Name", tsk.TaskId);
                ViewData["Task"] = selectTask;
            }

            ObjectId empId;
            isValid = ObjectId.TryParse(EmpId, out empId);
            if (isValid)
            {
                var getQuery = Query<Employee>.EQ(e => e.EmpId, empId);
                IList<Employee> listEmp = new List<Employee>();
                var emp = _employee.FindOne(getQuery);
                listEmp.Add(emp);
                var selectEmp = new SelectList(listEmp, "EmpId", "FullName", emp.EmpId);
                ViewData["Employee"] = selectEmp;
            }

            List<Status> listStatus = new List<Status>();

            Status stT3 = new Status() { Name = "Not Started" };
            listStatus.Add(stT3);
            Status stT1 = new Status() { Name = "In-Process" };
            listStatus.Add(stT1);
            Status stT2 = new Status() { Name = "Complete" };
            listStatus.Add(stT2);
            Status stT5 = new Status() { Name = "Waiting Approval" };
            listStatus.Add(stT5);
            Status stT6 = new Status() { Name = "On Hold" };
            listStatus.Add(stT6);
            Status stT4 = new Status() { Name = "Cancelled" };
            listStatus.Add(stT4);

            var selectSt = new SelectList(listStatus, "Name", "Name", listStatus[1].Name);
            ViewData["Status"] = selectSt;

            return PartialView();
        }
        public PartialViewResult Edit(string Id)
        {
            var _tickets = mongoDatabase.GetCollection<TicketBase>("TicketBase");
            
            ObjectId tickId;
            var isValid = ObjectId.TryParse(Id, out tickId);

            if (isValid)
            {
                var getQuery = Query<TicketBase>.EQ(e => e.Id, tickId);
                var tick = _tickets.FindOne(getQuery);

                var _project = mongoDatabase.GetCollection<Project>("Project");
                var _employee = mongoDatabase.GetCollection<Employee>("Employee");

                ObjectId projId;
                isValid = ObjectId.TryParse(tick.ProjectId, out projId);
                IList<Project> listProject = new List<Project>();
                if (isValid)
                {
                    getQuery = Query<Project>.EQ(e => e.ProjectId, projId);
                    Project proj = _project.FindOne(getQuery);
                    listProject.Add(proj);
                    var selectProj = new SelectList(listProject, "ProjectId", "Name", proj.ProjectId);
                    ViewData["Project"] = selectProj;
                }

                ObjectId empId;
                isValid = ObjectId.TryParse(tick.AssignedToId, out empId);
                IList<Employee> listEmployee = new List<Employee>();
                if (isValid)
                {
                    getQuery = Query<Employee>.EQ(e => e.EmpId, empId);
                    Employee emp = _employee.FindOne(getQuery);
                    listEmployee.Add(emp);
                    var selectEmp = new SelectList(listEmployee, "EmpId", "FullName", tick.AssignedToId);
                    ViewData["Employee"] = selectEmp;
                }

                List<Status> listStatus = new List<Status>();

                Status stT3 = new Status() { Name = "Not Started" };
                listStatus.Add(stT3);
                Status stT1 = new Status() { Name = "In-Process" };
                listStatus.Add(stT1);
                Status stT2 = new Status() { Name = "Complete" };
                listStatus.Add(stT2);
                Status stT5 = new Status() { Name = "Waiting Approval" };
                listStatus.Add(stT5);
                Status stT6 = new Status() { Name = "On Hold" };
                listStatus.Add(stT6);
                Status stT4 = new Status() { Name = "Cancelled" };
                listStatus.Add(stT4);

                var selectSt = new SelectList(listStatus, "Name", "Name", tick.Status);
                ViewData["Status"] = selectSt;

                List<Status> listPriority = new List<Status>();
                Status stP3 = new Status() { Name = "Very Urgent" };
                listPriority.Add(stP3);
                Status stP1 = new Status() { Name = "Urgent" };
                listPriority.Add(stP1);
                Status stP2 = new Status() { Name = "Normal" };
                listPriority.Add(stP2);

                var selectPriority = new SelectList(listPriority, "Name", "Name", tick.Priority);
                ViewData["Priority"] = selectPriority;

                return PartialView("Edit",tick);
            }
            else
            {
                return PartialView("Error");
            }
        }
        public PartialViewResult EditMonitor(string Id)
        {
            var _monitor = mongoDatabase.GetCollection<DevBase>("DevBase");
            var _task = mongoDatabase.GetCollection<Task>("Task");
            var _employee = mongoDatabase.GetCollection<Employee>("Employee");

            ObjectId monId;
            var isValid = ObjectId.TryParse(Id, out monId);
            if (isValid)
            {
                var getQuery = Query<DevBase>.EQ(e => e.Id, monId);
                var mon = _monitor.FindOne(getQuery);

                ObjectId taskId;
                isValid = ObjectId.TryParse(mon.TaskId, out taskId);
                if (isValid)
                {
                    getQuery = Query<Task>.EQ(e => e.TaskId, taskId);
                    IList<Task> listTask = new List<Task>();
                    var tsk = _task.FindOne(getQuery);
                    listTask.Add(tsk);
                    var selectTask = new SelectList(listTask, "TaskId", "Name", tsk.TaskId);
                    ViewData["Task"] = selectTask;
                }

                ObjectId empId;
                isValid = ObjectId.TryParse(mon.EmpId, out empId);
                if (isValid)
                {
                    getQuery = Query<Employee>.EQ(e => e.EmpId, empId);
                    IList<Employee> listEmp = new List<Employee>();
                    var emp = _employee.FindOne(getQuery);
                    if (emp != null && emp.IsActive == true)
                    {
                        listEmp.Add(emp);
                        var selectEmp = new SelectList(listEmp, "EmpId", "FullName", emp.EmpId);
                        ViewData["Employee"] = selectEmp;
                    }
                }

                List<Status> listStatus = new List<Status>();

                Status stT3 = new Status() { Name = "Not Started" };
                listStatus.Add(stT3);
                Status stT1 = new Status() { Name = "In-Process" };
                listStatus.Add(stT1);
                Status stT2 = new Status() { Name = "Complete" };
                listStatus.Add(stT2);
                Status stT5 = new Status() { Name = "Waiting Approval" };
                listStatus.Add(stT5);
                Status stT6 = new Status() { Name = "On Hold" };
                listStatus.Add(stT6);
                Status stT4 = new Status() { Name = "Cancelled" };
                listStatus.Add(stT4);

                var selectSt = new SelectList(listStatus, "Name", "Name", mon.Status);
                ViewData["Status"] = selectSt;

                return PartialView("EditMonitor", mon);
            }
            else
            {
                return PartialView("Error");
            }
        }