Inheritance: IDecisionsRepository
Example #1
0
        public void TestDecisionDetails()
        {
            IGenericRepository gens = new GenericRepository();

            IDecisionsRepository decisions = new DecisionsRepository();
            IList<Decision> decs = decisions.GetAllDecisionsPerParagraph(12);

            IList<DecisionDetails> details = UpdateUtils.GetDecisionDetails(decs);

               //   int j = recs.getAllRecommendationsByParagraph(12).Count;

            Assert.AreEqual(details.Count,decs.Count);
        }
Example #2
0
        public void TestAllDecisions()
        {
            IDecisionsRepository decs = new DecisionsRepository();

            IRecommendationsRepository recs = new RecommendationsRepository();

            int i = decs.GetAllDecisionsPerParagraph(12).Count;

             //   int j = recs.getAllRecommendationsByParagraph(12).Count;

            Assert.AreEqual(i, 2);
        }
        public ActionResult ParagraphDetailsEdit(int ReviewID, int PALibID)
        {
            try
            {
                ITaxonRepository taxon = new TaxonRepository();
                IReviewRepository reviews = new ReviewRepository();
                IGenericRepository generic = new GenericRepository();
                IMeetingLibRepository mlib = new MeetingLibRepository();
                IMembershipRepository members = new MembershipRepository();
                ICommentsRepository comments = new CommentsRepository();
                IDocumentsRepository docs = new DocumentsRepository();
                IRecommendationsRepository recs = new RecommendationsRepository();
                IDecisionsRepository decisions = new DecisionsRepository();

                var review = reviews.getSingleReview(ReviewID);
                review.TaxonName = taxon.getReviewTaxonName(review.ID, review.Taxontype, review.Kingdom);

                List<Actor> userDetails = GetUserDetails();
                ViewData["allactorsadd"] = new SelectList(userDetails,"UserName","UserDetails");
                ViewData["selectedactorsedit"] =
                ViewData["allactorsedit"] =
                ViewData["selectedactorsadd"] = ViewData["allactors2"] = ViewData["allactorsadd"];

                ViewData["PATitle"] = review.TaxonName + " [" + review.CtyShort + "]";
                ViewData["MeetingsA"] = ViewData["DecMeetings"] = ViewData["LiftedMeetings"] = new SelectList(generic.getAllMeetingsSelect(), "ID", "Description");

               // ViewData["Roles"] = new SelectList(members.getAllRoles());
                ViewData["roles"] = new SelectList(UpdateUtils.getViewersList());
                ViewData["PALib"] = reviews.getSinglePALib(PALibID);

                //GETTING THE PACTIONLIB TO RETRIEVE RECOMMENDATIONS/DECISIONS VALUES
                ParagraphActionLib palib = generic.getPActionLib(PALibID);
                ViewData["NeedsRecommendation"] = palib.Recommendations;
                ViewData["NeedsDecision"] = palib.Decisions;
                ViewData["NeedsConcern"] = palib.ConcernVisible;

                //END GETTING RECOMMENDATIONS/DECISIONS

                ViewData["ReviewID"] = ReviewID;
                ParagraphActionDetails pad = reviews.getParagraphDetails(PALibID, ReviewID);

                ViewData["Meetings"] = new SelectList(generic.getAllMeetingsSelect(), "ID", "Description",
                                                      pad.MeetingID);

                ViewData["DateStarted"] = pad.DateStarted.ToShortDateString();
                ViewData["Deadline"] = pad.Deadline.ToShortDateString();
                ViewData["concerns"] = new SelectList(generic.getAllLevelofConcerns(), "Description", "Description");
               // ViewData["concernlevel"]= reviews.getConcernForReview(ReviewID);
                ViewData["concernlevel"] = generic.getConcernForParagraphAction(pad.ID);
                ViewData["contributor"] = null;

                if (pad != null)
                {
                    if (Request.IsAuthenticated)
                    {
                        var user = UpdateUtils.getCurrentMembershipUser();
                        var roles = Roles.GetRolesForUser();
                        if (roles.Contains(UpdateUtils.ROLE_DATA_CONTRIBUTOR))
                        {
                            ViewData["contributor"] = User.Identity.Name;
                        }

                        if (roles.Contains(UpdateUtils.ROLE_INTERMEDIATE_VIEWER))
                        {

                            ViewData["Comments"] = comments.getCommentsByID(pad.ID, UpdateUtils.PARAGRAPH_SOURCE,UpdateUtils.ROLE_INTERMEDIATE_VIEWER );
                            ViewData["Documents"] = docs.getDocumentsByID(pad.ID, UpdateUtils.PARAGRAPH_SOURCE, UpdateUtils.ROLE_INTERMEDIATE_VIEWER);

                            //ViewData["Documents"] = ViewData["Documents"] + docs.getDocumentsByID(pad.ID, UpdateUtils.PARAGRAPH_SOURCE, UpdateUtils.ROLE_PUBLIC_VIEWER);
                        }
                         if (roles.Contains(UpdateUtils.ROLE_FULL_VIEWER))
                        {

                             ViewData["Comments"] = comments.getCommentsByID(pad.ID, UpdateUtils.PARAGRAPH_SOURCE, UpdateUtils.ROLE_ALL);
                             ViewData["Documents"] = docs.getDocumentsByID(pad.ID, UpdateUtils.PARAGRAPH_SOURCE, UpdateUtils.ROLE_ALL);
                        }
                    }
                    else
                    {
                        ViewData["Comments"] = comments.getCommentsByID(pad.ID, UpdateUtils.PARAGRAPH_SOURCE, UpdateUtils.ROLE_PUBLIC_VIEWER );
                        ViewData["Documents"] = docs.getDocumentsByID(pad.ID, UpdateUtils.PARAGRAPH_SOURCE,  UpdateUtils.ROLE_PUBLIC_VIEWER);
                    }

                    IList<UsersParagraphLink> users = generic.getUserBySource(pad.ID, UpdateUtils.PARAGRAPH_SOURCE);
                    int usercount = users.Count;
                    for (int j = 0; j < usercount; j++)
                    {
                        users[j].UserID = Membership.GetUser(new Guid(users[j].UserID)).UserName;
                        if (User.Identity.IsAuthenticated)
                    {
                        var current_user = User.Identity.Name;
                        if (users[j].UserID == current_user)
                        {
                            ViewData["contributor"] = current_user;
                        }
                    }

                    }

                    ViewData["PActionID"] = pad.ID;
                    ViewData["ReviewID"] = ReviewID;
                    ViewData["PALibID"] = PALibID;
                    ViewData["recommendations"] = recs.getAllRecommendationsByParagraph(pad.ID);

                    ViewData["editmode"] = false;

                    //ViewData["decisions"] = decisions.GetAllDecisionsPerParagraph(pad.ID);
                    IList<Decision> decs = decisions.GetAllDecisionsPerParagraph(pad.ID);
                    ViewData["decisiondetails"] = UpdateUtils.GetDecisionDetails(decs);
                    ViewData["decisions"] = decs;

                    ViewData["decisiontypes"] = new SelectList(generic.GetAllDecisionTypes(), "Description",
                                                               "Description");

                    ViewData["tradeterms"] = new SelectList(generic.GetAllTradeTerms(), "Description",
                                                               "Description");

                    ViewData["selectedactorsedit"] =
                        new SelectList(users, "UserID", "UserID");

                }

                ViewData["PADetails"] = pad;
                return View();

            }
            catch (Exception e)
            {
                return null;
            }
        }
        public ActionResult EditDecision(FormCollection collection)
        {
            IDecisionsRepository decisions = new DecisionsRepository();
            IGenericRepository generics = new GenericRepository();

            int ID = int.Parse(collection["ID"]);
            int ReviewID_ = int.Parse(collection["ReviewID"]);
            int PALibID_ = int.Parse(collection["PALibID"]);
            int SourceID = int.Parse(collection["SourceID"]);
            int SourceType = int.Parse(collection["SourceType"]);
            //decisions.DeleteDecision(ID);

            Decision decision = DB.Get<Decision>(ID);

            ViewData["decision"] = decision;
            ViewData["editmode"] = true;

            //SourceID is the ParagraphActionID actually

            IList<Decision> decs = decisions.GetAllDecisionsPerParagraph(SourceID);

            ViewData["decisiondetails"] = UpdateUtils.GetDecisionDetails(decs);

            ViewData["decisions"] = decs;

            //ViewData["Comments"] = comments.getCommentsByID(SourceID, SourceType);
            ViewData["ReviewID"] = ReviewID_;
            ViewData["PALibID"] = PALibID_;
            ViewData["PActionID"] = SourceID;
            ViewData["ID"] = ID;

            ViewData["MeetingsA"] = new SelectList(generics.getAllMeetingsSelect(), "ID", "Description");
            ViewData["DecMeetings"] = new SelectList(generics.getAllMeetingsSelect(), "ID", "Description", decision.SuspensionCommitteeID);
            ViewData["LiftedMeetings"] = new SelectList(generics.getAllMeetingsSelect(), "ID", "Description", decision.LigftingCommitteeID);
            ViewData["decisiontypes"] = new SelectList(generics.GetAllDecisionTypes(), "Description",
                                                          "Description", decision.DecisionType);

            ViewData["tradeterms"] = new SelectList(generics.GetAllTradeTerms(), "Description",
                                                       "Description",decision.TradeTerms);

            return PartialView("Decisions");
        }
        public ActionResult DeleteDecision(FormCollection collection)
        {
            //ICommentsRepository comments = new CommentsRepository();
            IDecisionsRepository decisions = new DecisionsRepository();
            IGenericRepository generics = new GenericRepository();

            int ID = int.Parse(collection["ID"]);
            int ReviewID_ = int.Parse(collection["ReviewID"]);
            int PALibID_ = int.Parse(collection["PALibID"]);
            int SourceID = int.Parse(collection["SourceID"]);
            int SourceType = int.Parse(collection["SourceType"]);
            decisions.DeleteDecision(ID);

            //SourceID is the ParagraphActionID actually

            IList<Decision> decs = decisions.GetAllDecisionsPerParagraph(SourceID);

            ViewData["decisiondetails"] = UpdateUtils.GetDecisionDetails(decs);

            ViewData["decisions"] = decs;

            //ViewData["Comments"] = comments.getCommentsByID(SourceID, SourceType);
            ViewData["ReviewID"] = ReviewID_;
            ViewData["PALibID"] = PALibID_;
            ViewData["PActionID"] = SourceID;

            ViewData["MeetingsA"] =
            ViewData["DecMeetings"] =
            ViewData["LiftedMeetings"] = new SelectList(generics.getAllMeetingsSelect(), "ID", "Description");
            ViewData["decisiontypes"] = new SelectList(generics.GetAllDecisionTypes(), "Description",
                                                          "Description");

            ViewData["tradeterms"] = new SelectList(generics.GetAllTradeTerms(), "Description",
                                                       "Description");

            ViewData["editmode"] = false;

            return PartialView("Decisions");

            //return RedirectToAction("ParagraphDetailsEdit", new { ReviewID = ReviewID_, PALibID = PALibID_ });
            //return View();
        }
        public ActionResult CreateDecision(FormCollection collection)
        {
            try {
                // TODO: Add insert logic here

                IGenericRepository generics = new GenericRepository();

                string decisionnotes = collection["decision"].ToString();
                int decMeetingId = int.Parse(collection["DecMeetings"].ToString());

                int decisionType = generics.getExternalRef(collection["decisiontypes"].ToString(),UpdateUtils.TYPE_DECISION);
                int tradeTerms = generics.getExternalRef(collection["tradeterms"].ToString(),UpdateUtils.TYPE_TRADETERMS);

                int PActionID = int.Parse(collection["SourceID"].ToString());

                IDecisionsRepository decisions = new DecisionsRepository();
                IGenericRepository generic = new GenericRepository();
                Decision dec = new Decision();

                dec.AddedDate = DateTime.Now;
                dec.DecisionType = decisionType;
                dec.ParagraphActionID = PActionID;
                dec.Notes = decisionnotes;
                dec.TradeTerms = tradeTerms;
                dec.SuspensionCommitteeID = decMeetingId;

                if (collection["suspensiondate"] != null && collection["suspensiondate"].Length > 0)
                {
                    dec.SuspensionDate = DateTime.Parse(collection["suspensiondate"].ToString());
                }

                if (collection["lifteddate"] != null && collection["lifteddate"].Length > 0) {
                    DateTime liftedDate = DateTime.Parse(collection["lifteddate"].ToString());
                    dec.SuspensionDate = liftedDate;
                }

                if (collection["LiftedMeetings"] != null && collection["LiftedMeetings"].Length > 0) {
                    int liftedCommitteeId = int.Parse(collection["LiftedMeetings"].ToString());
                    dec.LigftingCommitteeID = liftedCommitteeId;
                }

                int i = decisions.SaveDecision(dec);

                ViewData["MeetingsA"] =
                ViewData["DecMeetings"] =
                ViewData["LiftedMeetings"] = new SelectList(generic.getAllMeetingsSelect(), "ID", "Description");

                //ViewData["DecCommittees"] = ViewData["LiftedCommittees"]= new SelectList(generic.getAllCommitteesSelect(), "ID", "Description");
                IList<Decision> decs = decisions.GetAllDecisionsPerParagraph(PActionID);

                ViewData["decisiondetails"] = UpdateUtils.GetDecisionDetails(decs);

                ViewData["decisions"] = decs;

                //ViewData["decisions"] = decisions.GetAllDecisionsPerParagraph(PActionID);
                ViewData["ReviewID"] = int.Parse(collection["ReviewID"]);
                ViewData["PALibID"] = int.Parse(collection["PALibID"]);
                ViewData["PActionID"] = PActionID;

                ViewData["decisiontypes"] = new SelectList(generic.GetAllDecisionTypes(), "Description",
                                                           "Description");

                ViewData["tradeterms"] = new SelectList(generic.GetAllTradeTerms(), "Description",
                                                           "Description");

                ViewData["editmode"] = false;

                return PartialView("Decisions");

                //return RedirectToAction("Index");
            }
            catch {
                return RedirectToAction("Search", "SearchReview");
            }
        }