Inheritance: IReviewRepository
        public void getSingleReviewTest()
        {
            IReviewRepository reviews = new ReviewRepository();

            ReviewDesc review = reviews.getSingleReview(6);

            Assert.AreEqual(review.TaxonName, "test");
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                ITaxonRepository taxon = new TaxonRepository();
                IGenericRepository generics = new GenericRepository();
                IReviewRepository reviews = new ReviewRepository();
                // TODO: Add insert logic here
                TblReview r = new TblReview();

                int kingdom = 0;
                int reviewtype = 0;
                kingdom = collection["addkingdom"].Equals("animal") ?
                    generics.getExternalRef(UpdateUtils.ANIMALS, UpdateUtils.TYPE_KINGDOM) :
                    generics.getExternalRef(UpdateUtils.PLANTS, UpdateUtils.TYPE_KINGDOM);

                //reviewtype = collection["reviewtype"].Equals("normal") ?
                //    generics.getExternalRef(UpdateUtils.REVIEW_NORMAL, UpdateUtils.TYPE_REVIEW) :
                //    generics.getExternalRef(UpdateUtils.REVIEW_ADHOC, UpdateUtils.TYPE_REVIEW);

                r.CountryID = int.Parse(collection["countries"]);
                r.AddedBy = 2;
                r.AddedByName= Membership.GetUser().ToString();
                r.DateAdded = DateTime.Now;
                r.PhaseID = int.Parse(collection["addphase"]);
                int speciesId =  int.Parse(collection["species"]);
                r.TaxonID = speciesId;
                r.TaxonLevel = generics.getExternalRef(UpdateUtils.SPECIES, UpdateUtils.TYPE_TAXONLEVEL);
                r.KingdomID = kingdom;
               // r.CommitteeID = int.Parse(collection["committee"]);
                r.CommitteeID = 1;
                r.ReviewDate = DateTime.Now;
                r.ReviewType = 1;

                int ID= taxon.SaveReview(r);

                ReviewStatus rs = new ReviewStatus();
                rs.Status = generics.getExternalRef(UpdateUtils.SELECTION, UpdateUtils.REVIEWSTATUS);
                rs.DateAdded = DateTime.Now;
                rs.ReviewID = ID;
                reviews.saveReviewStatus(rs);

              //  return RedirectToAction("List","AddReview");
                return RedirectToAction("Details", "ProcessReview", new {id = ID});
            }
            catch
            {
                //Do nothing - caught below
            }
            return RedirectToAction("AddReview", "AddReview");
        }
Exemple #3
0
        //public  int deleteReview(int id)
        //{
        //    return DB.Delete().From<Review>().Where(Review.IdColumn).IsEqualTo(id).Execute();
        //}
        public void deleteReview(TblReview r)
        {
            r.DeletedDate = DateTime.Now;
               IReviewRepository reviews = new ReviewRepository();
            int reviewID = r.Id;

            var paragraphs = reviews.getParagraphActionByReview(reviewID);
            foreach (var paragraphAction in paragraphs)
            {
                DB.Delete(paragraphAction);
            }

               DB.Save(r);
               DB.Delete(r);
        }
        //public  int deleteReview(int id)
        //{

        //    return DB.Delete().From<Review>().Where(Review.IdColumn).IsEqualTo(id).Execute();

        //}

        public void deleteReview(TblReview r)
        {
            r.DeletedDate = DateTime.Now;
            IReviewRepository reviews = new ReviewRepository();
            int reviewID = r.Id;

            var paragraphs = reviews.getParagraphActionByReview(reviewID);

            foreach (var paragraphAction in paragraphs)
            {
                DB.Delete(paragraphAction);
            }

            DB.Save(r);
            DB.Delete(r);
        }
Exemple #5
0
        public static int InsertParagraphActionForm(FormCollection collection)
        {
            IReviewRepository reviews = new ReviewRepository();
            IGenericRepository generics = new GenericRepository();

            ParagraphAction pa = new ParagraphAction();

            int palibid = int.Parse(collection["PALibID"]);
            int reviewid = int.Parse(collection["ReviewID"]);
            pa.PALibID = palibid;
            pa.DateStarted = DateTime.Parse(collection["pda_started_date"].ToString());
            pa.DeadlineDate = DateTime.Parse(collection["pda_deadline_date"].ToString());
            pa.MeetingID = int.Parse(collection["meetings"]);
            pa.ReviewID = reviewid;
            //string concern = collection["concerns"].ToString();)

            if (collection["concerns"] != null)
            {
                string concern = collection["concerns"].ToString();
                switch(concern)
                {
                    case UpdateUtils.URGENT_CONCERN:
                        pa.ConcernID = UpdateUtils.URGENT_CONCERN_ID;

                        break;
                    case UpdateUtils.POSSIBLE_CONCERN:
                        pa.ConcernID = UpdateUtils.POSSIBLE_CONCERN_ID;
                        break;
                    case UpdateUtils.LEAST_CONCERN:
                        pa.ConcernID = UpdateUtils.LEAST_CONCERN_ID;
                        break;
                    case UpdateUtils.NOT_CLASSIFIED:
                        pa.ConcernID = UpdateUtils.NOT_CLASSIFIED_ID;
                        break;
                }
                TblReview review = reviews.getSingleReviewEdit(reviewid);
                review.ConcernID = pa.ConcernID;
                DB.Save(review);
                generics.resetCurrentConcernForReview(reviewid);
                pa.CurrentConcern = true;
            }
            else
            {
                pa.ConcernID = UpdateUtils.NOT_CLASSIFIED_ID;
                pa.CurrentConcern = true;
            }

            string completed = collection["completed"];

            if ((completed!=null) && (completed.Equals("on")))
            {
                DateTime dateCompleted = DateTime.Now;
                if (collection["pda_completed_date"] != null && collection["pda_completed_date"].Length > 0) {
                    dateCompleted = DateTime.Parse(collection["pda_completed_date"]);
                    pa.CompletedDate = dateCompleted;
                }
                else {
                    pa.CompletedDate = dateCompleted;
                }
                pa.Completed = true;
            }

            pa.DateAdded = DateTime.Now;
            return reviews.SavePA(pa);
        }
        /**
         * This function should construct and send the email finally
         *
         * NOT FINISHED!!!
         */
        private void build_send_and_log_message(SigtradeUser user, MessageTemplate template, ParagraphActionCollection paras)
        {
            //create the mail message
            MailMessage mail = new MailMessage();

            //set the addresses
            mail.From = new MailAddress("*****@*****.**");

            //Finding user through membership Api

            MembershipUser my_user = Membership.GetUser(new Guid(user.userid));
            mail.To.Add(my_user.Email);
            //mail.To.Add(user); //MUST USE MEMBERSHIP API TO FIND USER AND PROFILE SETTINGS (INCL EMAIL) NOT WORKING

            //set the content
            mail.Subject = template.Title;
            StringBuilder emailBody = new StringBuilder();

            var userProfile = Profile.GetProfile(my_user.UserName);

            mail.Body = template.Body;
            emailBody.AppendLine("Dear " + userProfile.first_name + ' ' + userProfile.last_name);
            emailBody.AppendLine(template.Body);

            //Need to get the paragraph details
            IReviewRepository reviews = new ReviewRepository();
            ITaxonRepository taxon = new TaxonRepository();

            foreach (ParagraphAction para in paras)
            {
                var review = reviews.getSingleReview(para.ReviewID);
                var paragraph = reviews.getSinglePALib(para.PALibID);
                review.TaxonName = taxon.getReviewTaxonName(review.ID, review.Taxontype, review.Kingdom);
                //mail.Body = mail.Body.Concat(para.DeadlineDate.ToString()); //SOME SORT OF WARNING HERE!
                var review_type = review.TaxonName + " [" + review.CtyShort + "]";
                emailBody.AppendLine("Review:" + review_type);
                emailBody.AppendLine("Paragraph details: " + paragraph.Action + " (" + ((DateTime)para.DeadlineDate).ToShortDateString() + ')');
                emailBody.AppendLine();
                //mail.Body = mail.Body;
            }
            emailBody.AppendLine();
            emailBody.AppendLine(Resources.SigTrade.emailFooter);
            mail.Body = emailBody.ToString();

            //send the message
            SmtpClient smtp = new SmtpClient(UpdateUtils.SMTP_RELAY_SERVER,25);
            try
            {
                smtp.Send(mail);
            }
            catch(SmtpException e)
            {

            }

            //HERE WE SHOULD WRITE TO THE LOG TABLE.
            //Prepare the MessageLog object
            MessageLog log = new MessageLog();
            log.SentTo = my_user.Email;
            log.SentAt = DateTime.Today;
            log.Title = template.Title;
            log.Body = emailBody.ToString();
            write_to_message_log(log);
        }
        public ActionResult SaveCompleted(FormCollection collection)
        {
            try
            {
                IGenericRepository generics = new GenericRepository();
                IReviewRepository reviews = new ReviewRepository();
                int PActionID = int.Parse(collection["SourceID"].ToString());

                string completed = collection["ckCompleted"];

                DateTime dateCompleted = DateTime.Now;

                ParagraphAction PAction = reviews.getParagraphActionbyID(PActionID);
                int ReviewID = int.Parse(PAction.ReviewID.ToString());

                if (collection["selectedactorsedit"] != null)
                {
                    collection["users"] = collection["selectedactorsedit"];
                    UpdateUtils.InsertUsersPerParagraph(collection, PActionID, UpdateUtils.PARAGRAPH_SOURCE);
                }
               // string selected = collection["selectedactorsedit"].ToString();
              //  string[] listselected = selected.Split(',');

              //  int count = listselected.Length;
              //  for (int j = 0; j < count; j++)
              //  {
              //      string key = Membership.GetUser(listselected[j]).ProviderUserKey.ToString();
              //  }

                if (completed != null)
                {
                    PAction.Completed = true;
                    if (collection["edit_date_completed"] != null && collection["edit_date_completed"].Length > 0)
                    {
                        dateCompleted = DateTime.Parse(collection["edit_date_completed"]);
                    }
                   PAction.CompletedDate = dateCompleted;
                }
                else
                {
                    PAction.Completed = false;
                    PAction.DateModified = DateTime.Now;
                }
                //Save the rest of the data
                var deadlineDate = collection["Deadline"] == null ? ((DateTime)PAction.DateStarted).AddDays(30) : DateTime.Parse(collection["Deadline"].ToString());
                var startedDate = DateTime.Parse(collection["DateStarted"]);
                PAction.DeadlineDate = deadlineDate;
                PAction.DateStarted = startedDate;
                if (collection["concerns"] != null)
                {
                    string concern = collection["concerns"];
                    switch (concern) {
                        case UpdateUtils.URGENT_CONCERN:
                            PAction.ConcernID = UpdateUtils.URGENT_CONCERN_ID;

                            break;
                        case UpdateUtils.POSSIBLE_CONCERN:
                            PAction.ConcernID = UpdateUtils.POSSIBLE_CONCERN_ID;
                            break;
                        case UpdateUtils.LEAST_CONCERN:
                            PAction.ConcernID = UpdateUtils.LEAST_CONCERN_ID;
                            break;
                        case UpdateUtils.NOT_CLASSIFIED:
                            PAction.ConcernID = UpdateUtils.NOT_CLASSIFIED_ID;
                            break;
                    }

                    ParagraphAction topPA = generics.getParagraphActionPerReview(PAction.ReviewID.Value);
                    if (topPA.Id == PAction.Id)
                    {
                        TblReview review = reviews.getSingleReviewEdit(PAction.ReviewID);
                        review.ConcernID = PAction.ConcernID;
                        DB.Save(review);
                        generics.resetCurrentConcernForReview(PAction.ReviewID.Value);
                        PAction.CurrentConcern = true;
                    }

                }
                PAction.MeetingID = Int32.Parse(collection["Meetings"]);
                PAction.DateModified = DateTime.Now;

                int i= reviews.SavePA(PAction);

                return RedirectToAction("Details","ProcessReview", new {ID=ReviewID});
            }
            catch
            {
                //return View();
                return null;

            }
        }
        public ActionResult EditReview(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
                IReviewRepository reviews = new ReviewRepository();
                ITaxonRepository taxons = new TaxonRepository();
                TblReview review = reviews.getSingleReviewEdit(id);
                IGenericRepository generics = new GenericRepository();

                int kingdom = 0;
                int reviewtype = 0;
                kingdom = collection["kingdom"].Equals("animal") ?
                    generics.getExternalRef(UpdateUtils.ANIMALS, UpdateUtils.TYPE_KINGDOM) :
                    generics.getExternalRef(UpdateUtils.PLANTS, UpdateUtils.TYPE_KINGDOM);

                //reviewtype = collection["reviewtype"].Equals("normal") ?
                //    generics.getExternalRef(UpdateUtils.REVIEW_NORMAL, UpdateUtils.TYPE_REVIEW) :
                //    generics.getExternalRef(UpdateUtils.REVIEW_ADHOC, UpdateUtils.TYPE_REVIEW);

                review.CountryID = int.Parse(collection["countries"]);
                review.AddedBy = 2;
                review.DateAdded = DateTime.Now;
                review.PhaseID = int.Parse(collection["addphase"]);
                review.TaxonID = int.Parse(collection["species"]); ;
                review.TaxonLevel = generics.getExternalRef(UpdateUtils.SPECIES, UpdateUtils.TYPE_TAXONLEVEL);
                review.KingdomID = kingdom;
                //review.CommitteeID = int.Parse(collection["committee"]);
                review.CommitteeID = 1;
                //r.ReviewDate = DateTime.Now;
                //r.ReviewType = reviewtype;

                int ID = taxons.SaveReview(review);

                //ReviewStatus rs = new ReviewStatus();
                //rs.Status = generics.getExternalRef(UpdateUtils.SELECTION, UpdateUtils.REVIEWSTATUS);
                //rs.DateAdded = DateTime.Now;
                //rs.ReviewID = ID;
                //reviews.saveReviewStatus(rs);

                return RedirectToAction("List");
            }
            catch
            {
                return View();
            }
        }
Exemple #9
0
        public void testSpPALIbExtra()
        {
            IReviewRepository gen = new ReviewRepository();

            IList<PALibExtra> libs = gen.getAllPALibExtra(7);

            Assert.AreEqual(libs[0].Paragraph, "hello");
        }
        public ActionResult ParagraphDetails(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();

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

                ViewData["allactorsadd"] = new SelectList(Membership.GetAllUsers());
                ViewData["selectedactorsedit"]= ViewData["allactorsedit"]=ViewData["selectedactorsadd"]=ViewData["allactors2"] = ViewData["allactorsadd"];

                ViewData["PATitle"] = review.TaxonName + "-" + review.Taxontype + "\\" + review.CtyShort;
                ViewData["Committees"] = new SelectList(generic.getAllCommitteesSelect(), "ID", "Description");
                ViewData["Meetings"] = new SelectList(mlib.getAllMeetingLibs(), "MeetingLibID", "MeetingLibDesc");
                ViewData["Roles"] = new SelectList(members.getAllRoles());
                ViewData["PALib"] = reviews.getSinglePALib(PALibID);
                ViewData["ReviewID"] = ReviewID;
                ParagraphActionDetails pad = reviews.getParagraphDetails(PALibID, ReviewID);

                if (pad != null)
                {
                    ViewData["Comments"] = comments.getCommentsByID(pad.ID, UpdateUtils.PARAGRAPH_SOURCE,UpdateUtils.ROLE_ALL);
                    ViewData["Documents"] = docs.getDocumentsByID(pad.ID, UpdateUtils.PARAGRAPH_SOURCE, UpdateUtils.ROLE_ALL);

                    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;

                    }

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

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

            }
            catch
            {
                return null;
            }
        }
        public ActionResult ParagraphDetails(int ReviewID, int PALibID, FormCollection form)
        {
            try
            {
                ITaxonRepository taxon = new TaxonRepository();
                IReviewRepository reviews = new ReviewRepository();
                IMembershipRepository members = new MembershipRepository();

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

                ViewData["PATitle"] = review.TaxonName + "-" + review.Taxontype;

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

                ViewData["PADetails"] = pad;
                return View();
                //return RedirectToAction("Details");
            }
            catch
            {
                return null;
             }
        }
        //
        // GET: /ProcessReview/Details/5
        public ActionResult Details(int id)
        {
            int ReviewID = id;

            IReviewRepository reviews = new ReviewRepository();
            ITaxonRepository taxon = new TaxonRepository();
            IGenericRepository generics = new GenericRepository();

            ReviewDesc review = reviews.getSingleReview(ReviewID);
            review.TaxonName = taxon.getReviewTaxonName(review.ID, review.Taxontype, review.Kingdom);
            bool completed = generics.getOldDataImportedStatus(ReviewID);

            ViewData["para31_completed"] = completed;
            ViewData["Title"] = review.TaxonName + " [" + review.CtyShort + "]";
            ViewData["Review"] = review;
            //ViewData["PAction"] = reviews.getParagraphDetails(review.)

            ViewData["NextPALibID"] = reviews.getNextParagraphForReview(ReviewID);
            var current_reviews = reviews.getAllPALibExtra(ReviewID);
            ViewData["PALibs"] = current_reviews;

            ViewData["para_contributor"] = null;
            foreach (var currentReview in current_reviews)
            {
                if ((currentReview.ReviewID > 0)  && !currentReview.Completed && (!completed))
                {
                    IList<UsersParagraphLink> users = generics.getUserBySource(currentReview.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["para_contributor"] = current_user;
                            }
                        }

                    }
                }
            }

            return View();
        }
        private void saveSpeciesForReview()
        {
            ITaxonRepository Taxon = new TaxonRepository();
            IGenericRepository gen = new GenericRepository();
            IReviewRepository rr = new ReviewRepository();

            if (TempData["CurrentData"] != null)
            {
                DataTable dt = (DataTable)TempData["CurrentData"];
                int rowcount = dt.Rows.Count;
                ITaxonRepository taxon = new TaxonRepository();
                for (int i = 0; i < rowcount; i++)
                {
                    DataRow dr = dt.Rows[i];

                    TblReview r = new TblReview();

                    r.PhaseID = int.Parse(dr[1].ToString());
                    r.KingdomID = taxon.getTaxonLevelID(dr[7].ToString());
                    r.TaxonLevel = taxon.getTaxonLevelID(dr[2].ToString());
                    r.TaxonID = int.Parse(dr[4].ToString());
                    r.DateAdded = DateTime.Now;
                    r.CountryID = int.Parse(dr[6].ToString());

                    int ID = taxon.SaveReview(r);

                    ReviewStatus rs = new ReviewStatus();
                    rs.Status = gen.getExternalRef(UpdateUtils.SELECTION, UpdateUtils.REVIEWSTATUS);
                    rs.DateAdded = DateTime.Now;
                    rs.ReviewID = ID;
                    rr.saveReviewStatus(rs);

                }
            }
        }
        private IList<ReviewDesc> GetAllReviews(int? pageIndex)
        {
            ITaxonRepository Taxon = new TaxonRepository();
            IReviewRepository reviews = new ReviewRepository();
               // IList<ReviewDesc> review = Taxon.GetAllReviews();

            int currentIndex = (int) (pageIndex ?? 1);

            //int count = review.Count;
               // int count = Taxon.getAllReviews().Count;
            SqlQuery query = Select.AllColumnsFrom<VwAllReview>();
            int count = query.GetRecordCount();
            ViewData["TotalItemCount"] = count;
            ViewData["PageNumber"] = currentIndex;
            ViewData["PageSize"] = UpdateUtils.DEFAULT_PAGE_SIZE;

            IList<ReviewDesc> review = Taxon.GetAllReviewsPaged(currentIndex, UpdateUtils.DEFAULT_PAGE_SIZE);

            var sortedReviews = from r in review
                                orderby r.CtyShort
                                select r;

            int pagedCount = review.Count;

            if ( pagedCount > 0)
            {
                for (int i = 0; i < pagedCount; i++)
                {
                    review[i].TaxonName = Taxon.getReviewTaxonName(review[i].ID, review[i].Taxontype,
                                                                    review[i].Kingdom);

                    review[i].Paragraph = Taxon.getParagraphStagePerReview(review[i].ID);

                    review[i].Concern = reviews.getConcernForReview(review[i].ID);
                    review[i].DeadlineDate = Taxon.getDeadlineDatePerReview(review[i].ID);

                }
            }

            if (pagedCount <= 0)
                review = null;
            return review;
        }
        //GET: /AddReview/ListAll
        public ActionResult ListAll(int? page, int? searched)
        {
            if (page.HasValue) {
                //return RedirectToAction("ListAll", new { collection = (FormCollection)Session["search_form"], page = page, searched = 1 });

                ITaxonRepository RPtaxons = new TaxonRepository();
                IReviewRepository RPreviews = new ReviewRepository();

                string freesearch, searchcountry, searchall = "";

                FormCollection collection = (FormCollection)Session["search_form"];

                try {
                    //freesearch = collection["search1"];
                    freesearch = collection["search_free"];
                    searchcountry = collection["search2"];
                    searchall = collection["search3"];

                    IList<ReviewDesc> reviews = null;
                    IList<ReviewDesc> reviews2 = null;

                    //return reviews;

                    string nodata = "No search results found";
                    if (freesearch != null) {
                        var search = collection["searchspecies"];
                        if (search.IndexOf('-') == -1)
                            return RedirectToAction("Search", "SearchReview");
                        string searchstring = collection["searchspecies"];
                        searchstring = searchstring.Trim();
                        string[] splitstring = searchstring.Split('-');

                        //Have changed coding now - the genus species is returned, so need to split further to keep same method
                        string[] taxonString = splitstring[0].Split(' ');

                        reviews = RPreviews.getAllReviewsbyFreeSearch(taxonString[0].Trim(), taxonString[1].Trim());
                    }
                    else if (searchcountry != null) {
                        string countryID = collection["searchcountry"];
                        if (countryID.ToUpper().Contains(UpdateUtils.SELECT_ALL)) {
                            reviews = this.GetAllReviews(null);

                        }
                        else {
                            int country = int.Parse(countryID);
                            reviews = RPreviews.getAllReviewsbyCountry(country);
                        }

                    }
                    else if (searchall != null) {
                        int phase = int.Parse(collection["phase"]);
                        string kingdom = collection["kingdom"];
                        //-2 is for select all
                        int genus = -2;
                        int species = -2;
                        int country = -2;

                        if (collection["agenus"] != null)
                            genus = int.Parse(collection["agenus"]);
                        if (collection["aspecies"] != null)
                            species = int.Parse(collection["aspecies"]);
                        if (collection["acountries"] != null) {
                            country = int.Parse(collection["acountries"]);
                        }

                        if (kingdom.Equals(UpdateUtils.ALL_KINGDOM.ToString())) {
                            IList<ReviewDesc> reviewstemp = RPreviews.getAllReviewsbySearchAll(phase, UpdateUtils.ANIMALS, genus, species, country);
                            reviews2 = RPreviews.getAllReviewsbySearchAll(phase, UpdateUtils.PLANTS, genus, species, country);

                            if (reviewstemp != null && reviews2 != null)
                                reviews = reviewstemp.Concat(reviews2).ToList();

                            if (reviewstemp == null && reviews2 != null)
                                reviews = reviews2;

                            if (reviewstemp != null && reviews2 == null)
                                reviews = reviewstemp;
                            else {
                                reviews = null;
                            }

                        }

                        else {
                            reviews = RPreviews.getAllReviewsbySearchAll(phase, kingdom, genus, species, country);
                        }

                    }

                    int count = 0;
                    if (reviews != null)
                        count = reviews.Count;

                    if (count > 0) {
                        for (int i = 0; i < count; i++) {

                            //        reviews[i].TaxonName = RPtaxons.getReviewTaxonName(reviews[i].TaxonID, reviews[i].Taxontype,
                            //                                                        reviews[i].Kingdom);
                            reviews[i].Paragraph = RPtaxons.getParagraphStagePerReview(reviews[i].ID);
                            reviews[i].Concern = RPreviews.getConcernForReview(reviews[i].ID);
                            reviews[i].DeadlineDate = RPtaxons.getDeadlineDatePerReview(reviews[i].ID);
                        }

                    }

                    int ij = 10;
                    if (reviews == null) {

                        return RedirectToAction("Search", "SearchReview", new { NoSearchResults = true });
                    }
                    var sortedReviews = from r in reviews
                                        orderby r.DateAdded
                                        select r;
                    //PageIndex
                    int PageIndex = 0;
                    if (page.HasValue)
                        PageIndex = (int)page;

                    IPagedList<ReviewDesc> pagedReview = sortedReviews.ToPagedList(PageIndex, UpdateUtils.DEFAULT_PAGE_SIZE);

                    ViewData["AllReviews"] = pagedReview;//sortedReviews.ToPagedList(1,count);
                    ViewData["PageSize"] = UpdateUtils.DEFAULT_PAGE_SIZE;
                    ViewData["PageNumber"] = PageIndex;
                    ViewData["TotalItemCount"] = count;
                    return View();
                }
                catch {
                    return RedirectToAction("Search", "SearchReview");
                }

            }

            ViewData["AllReviews"] = this.GetAllReviews(page);

            return View();
        }
Exemple #16
0
        public static int InsertParagraphActionForm(FormCollection collection)
        {
            IReviewRepository reviews = new ReviewRepository();
            IGenericRepository generics = new GenericRepository();

            ParagraphAction pa = new ParagraphAction();

            int palibid = int.Parse(collection["PALibID"]);
            int reviewid = int.Parse(collection["ReviewID"]);
            pa.PALibID = palibid;
            pa.DateStarted = DateTime.Parse(collection["pda_started_date"].ToString());
            pa.DeadlineDate = DateTime.Parse(collection["pda_deadline_date"].ToString());
            pa.MeetingID = int.Parse(collection["meetings"]);
            pa.ReviewID = reviewid;         
            //string concern = collection["concerns"].ToString();)

            if (collection["concerns"] != null)
            {
                string concern = collection["concerns"].ToString();
                switch(concern)
                {
                    case UpdateUtils.URGENT_CONCERN:
                        pa.ConcernID = UpdateUtils.URGENT_CONCERN_ID;
                        
                        break;
                    case UpdateUtils.POSSIBLE_CONCERN:
                        pa.ConcernID = UpdateUtils.POSSIBLE_CONCERN_ID;
                        break;
                    case UpdateUtils.LEAST_CONCERN:
                        pa.ConcernID = UpdateUtils.LEAST_CONCERN_ID;
                        break;
                    case UpdateUtils.NOT_CLASSIFIED:
                        pa.ConcernID = UpdateUtils.NOT_CLASSIFIED_ID;
                        break;
                }
                TblReview review = reviews.getSingleReviewEdit(reviewid);
                review.ConcernID = pa.ConcernID;
                DB.Save(review);
                generics.resetCurrentConcernForReview(reviewid);
                pa.CurrentConcern = true;
            }
            else
            {
                pa.ConcernID = UpdateUtils.NOT_CLASSIFIED_ID;
                pa.CurrentConcern = true;
            }
            
            string completed = collection["completed"];
           
            if ((completed!=null) && (completed.Equals("on")))
            {
                DateTime dateCompleted = DateTime.Now;
                if (collection["pda_completed_date"] != null && collection["pda_completed_date"].Length > 0) {
                    dateCompleted = DateTime.Parse(collection["pda_completed_date"]);
                    pa.CompletedDate = dateCompleted;
                }
                else {
                    pa.CompletedDate = dateCompleted;
                }             
                pa.Completed = true;
            }

            pa.DateAdded = DateTime.Now;
            return reviews.SavePA(pa);
        }
        public ActionResult ParagraphDetailsAdd(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();

                ReviewDesc review = reviews.getSingleReview(ReviewID);
                ViewData["concernlevel"] = reviews.getConcernForReview(ReviewID.Value);
                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["committees"] = new SelectList(generic.getAllCommitteesSelect(), "ID", "Description");
                ViewData["meetings1"] = new SelectList(mlib.getAllMeetingLibs(), "MeetingLibID", "MeetingLibDesc");
                ViewData["meetings"] =new SelectList(generic.getAllMeetingsSelect(), "ID", "Description");
                ViewData["concerns"] = new SelectList(generic.getAllLevelofConcerns(), "Description", "Description");
                //ViewData["roles"] = new SelectList(members.getAllRoles());
                ViewData["rolesc"] =
                ViewData["rolesd"]=new SelectList(UpdateUtils.getViewersList());
                ViewData["paction"] = reviews.getSinglePALib(PALibID);
                ViewData["PALib"] = PALibID;
                ViewData["ReviewID"] = ReviewID;
                ViewData["concernlevel"] = reviews.getConcernForReview(ReviewID.Value);

                return View();

            }
            catch
            {
                return null;
            }
        }
        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 void testParagraphActionDetails()
        {
            IReviewRepository reviews = new ReviewRepository();

             ParagraphActionDetails pad = reviews.getParagraphDetails(1, 6);

             Assert.AreEqual(pad.CommitteeDesc, "hello");

             //Assert.IsNull(pad);
             //Assert.AreEqual(count,0);
        }
        public ActionResult EditReview(int id)
        {
            IReviewRepository reviews = new ReviewRepository();
            IGenericRepository generics = new GenericRepository();
            ITaxonRepository taxons = new TaxonRepository();

            TblReview review = reviews.getSingleReviewEdit(id);
            ViewData["addphase"] = new SelectList(generics.getAllPhase(), "ID", "PhaseDesc",review.PhaseID);
            ViewData["committee"] = new SelectList(generics.getAllCommittees(), "ID", "Description", review.CommitteeID);

            int animal = generics.getExternalRef(UpdateUtils.ANIMALS, UpdateUtils.TYPE_KINGDOM);
            int kingdom = (int) review.KingdomID;
            IList<AGeneralTaxon> lists_countries, lists_genus, lists_species = null;
            int SpeciesID = review.TaxonID.GetValueOrDefault();
            Taxons genus = taxons.getTaxonbySpecies(SpeciesID, (int) review.KingdomID);

            if (review.KingdomID == animal)
            {
                lists_countries = taxons.getCountries(SpeciesID, UpdateUtils.SPECIES, UpdateUtils.ANIMALS);
                lists_genus = taxons.getAGenus();
                lists_species= taxons.getASpeciesbyGenus(genus.genrecid);
            }
            else
            {
                lists_countries = taxons.getCountries(SpeciesID, UpdateUtils.SPECIES, UpdateUtils.PLANTS);
                lists_genus = taxons.getPGenus();
                lists_species= taxons.getPSpeciesbyGenus(genus.genrecid);
            }

            ViewData["animal"] = animal;
            ViewData["kingdom"] = kingdom;
            ViewData["countries"] = new SelectList(lists_countries, "RecID", "TaxonName", review.CountryID);
            ViewData["genus"] = new SelectList(lists_genus, "RecID", "TaxonName", genus.genrecid);
            ViewData["species"] = new SelectList(lists_species, "RecID", "TaxonName", SpeciesID);

            return View();
        }