Ejemplo n.º 1
0
        public ActionResult DisjointTask(string id, VetTaskModel 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 <VetTaskModel> .Filter.Eq("_id", ObjectId.Parse(id));

                var update = Builders <VetTaskModel> .Update
                             .Set("assignees", assignees)
                             .Set("state", "Unassigned");

                var result = vetCollection.UpdateOne(filter, update);

                assignees = new List <string>();
                return(RedirectToAction("Details", new { id = id }));
            }
            else
            {
                task.assignees = assignees;

                var filter = Builders <VetTaskModel> .Filter.Eq("_id", ObjectId.Parse(id));

                var update = Builders <VetTaskModel> .Update
                             .Set("assignees", assignees);

                var result = vetCollection.UpdateOne(filter, update);

                assignees = new List <string>();
                return(RedirectToAction("Details", new { id = id }));
            }
        }
Ejemplo n.º 2
0
        public ActionResult DeleteComment(string id, VetTaskModel task, string comment)
        {
            VetTaskModel.Comment comment1 = new VetTaskModel.Comment();
            var singletask = vetCollection.AsQueryable <VetTaskModel>().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 <VetTaskModel> .Filter.Eq("_id", ObjectId.Parse(id));

            var update = Builders <VetTaskModel> .Update
                         .Set("Comments", comments);

            var result = vetCollection.UpdateOne(filter, update);

            return(RedirectToAction("AddComment", new { id = id }));
        }
Ejemplo n.º 3
0
        public ActionResult Create(VetTaskModel vetTask)
        {
            vetTask.posterName  = Session["Username"].ToString();
            vetTask.posterPhoto = Session["Img"].ToString();
            vetTask.taskType    = "Vet Task";
            vetTask.taskName    = "Vet - " + vetTask.dogName;

            var vol = volunteerCollection.AsQueryable <VolunteerModel>().SingleOrDefault(x => x.Name == vetTask.requester);

            vetTask.reqPhoto = vol.UserPhoto;
            vetTask.state    = "Unassigned";

            vetTask.FileList = documentsList;

            try
            {
                vetCollection.InsertOne(vetTask);
                deletedTask = new List <object>();
                deletedTask.Add(vetTask);
                documentsList        = new List <string>();
                Session["TaskCount"] = Int32.Parse(Session["TaskCount"].ToString()) + 1;
                return(RedirectToAction("Details", new { id = vetTask.Id }));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(string id, VetTaskModel task)
        {
            task.FileList = documentsList;
            try
            {
                var filter = Builders <VetTaskModel> .Filter.Eq("_id", ObjectId.Parse(id));

                var update = Builders <VetTaskModel> .Update

                             .Set("ImportanceLevel", task.ImportanceLevel)
                             .Set("requester", task.requester)
                             .Set("taskID", task.taskID)
                             .Set("taskName", task.taskName)
                             .Set("taskType", task.taskType)
                             .Set("posterName", task.posterName)
                             .Set("creationDate", task.creationDate)
                             .Set("state", task.state)
                             .Set("AdditionalInfo", task.AdditionalInfo)
                             .Set("pickupLocation", task.pickupLocation)
                             .Set("pickupVolunteer", task.pickupVolunteer)

                             .Set("appointmentAddress", task.appointmentAddress)

                             .Set("APDate", task.APDate)
                             .Set("APTime", task.APTime)
                             .Set("appointmentReason", task.appointmentReason)
                             .Set("appointmentNotes", task.appointmentNotes)
                             .Set("dropoffLocation", task.dropoffLocation)
                             .Set("dropoffVolunteer", task.dropoffVolunteer)
                             .Set("DODate", task.DODate)
                             .Set("DOTime", task.DOTime)
                             .Set("dogName", task.dogName)
                             .Set("dogBreed", task.dogBreed)
                             .Set("dogSize", task.dogSize)
                             .Set("dogNotes", task.dogNotes)
                             .Set("FileList", task.FileList);

                var result = vetCollection.UpdateOne(filter, update);
                deletedTask = new List <object>();
                task.Id     = ObjectId.Parse(id);
                deletedTask.Add(task);
                documentsList = new List <string>();
                //      documentsList = new List<VetTaskModel.documents>();

                return(RedirectToAction("Details", new { id = id }));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 5
0
        public ActionResult JoinTask(string id, VetTaskModel task)
        {
            assignees.Add(Session["UserId"].ToString());
            task.assignees = assignees;

            var filter = Builders <VetTaskModel> .Filter.Eq("_id", ObjectId.Parse(id));

            var update = Builders <VetTaskModel> .Update
                         .Set("assignees", assignees)
                         .Set("state", "Assigned");

            var result = vetCollection.UpdateOne(filter, update);

            assignees = new List <string>();
            Session["JoinedTaskCount"] = Int32.Parse(Session["JoinedTaskCount"].ToString()) + 1;
            return(RedirectToAction("Details", new { id = id }));
        }
Ejemplo n.º 6
0
        public ActionResult AddComment(string id, VetTaskModel task)
        {
            scomm.volunteerId    = Session["UserId"].ToString();
            scomm.comm           = task.singleComm;
            scomm.volunteerName  = Session["Username"].ToString();
            scomm.volunteerPhoto = Session["Img"].ToString();
            comments             = new List <VetTaskModel.Comment>();

            var singletask = vetCollection.AsQueryable <VetTaskModel>().SingleOrDefault(x => x.Id == new ObjectId(id));

            if (singletask.Comments == null || singletask.Comments.Count() == 0)
            {
                comments     = new List <VetTaskModel.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 <VetTaskModel> .Filter.Eq("_id", ObjectId.Parse(id));

            var update = Builders <VetTaskModel> .Update
                         .Set("Comments", comments)

                         .Set("singleComm", "");

            var result = vetCollection.UpdateOne(filter, update);

            return(RedirectToAction("AddComment", new { id = id }));
            //return RedirectToAction("Details", new { id = id });
        }
Ejemplo n.º 7
0
        public ActionResult CompleteTask(string id, VetTaskModel task)
        {
            var filter = Builders <VetTaskModel> .Filter.Eq("_id", ObjectId.Parse(id));

            var update = Builders <VetTaskModel> .Update
                         .Set("state", "Completed");

            var result = vetCollection.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"));
            }
        }