public ActionResult GetStudy(string SearchText)
        {
            try
            {
                if (pagemanager.IsPageValid((int)Session["FOGroupId"], 11))
                {
                    return(View("PageError"));
                }
                else
                {
                    NavManager.Logger((int)Session["FOUserId"], 11, DateTime.Now, Request.Url.AbsoluteUri);
                    int id   = (int)(Session["FOUserId"]);
                    var user = usermanager.GetUserByID(id);

                    var studies = studymanager.GetGrantedStudiesbyUserID(id);
                    GrantDenyStudyModels grant = new GrantDenyStudyModels();

                    foreach (var item in studies)
                    {
                        StudyModels std          = new StudyModels();
                        Study       sm           = new Study();
                        var         presentgroup = user.GroupID;
                        List <StudyStatusMapping> studyStatusMaps = mapGetter.GetAll().ToList <StudyStatusMapping>();

                        sm = studymanager.GetStudyByStudyId(item.StudyID);
                        var newStatus = (from status in studyStatusMaps
                                         where (status.DataSourceStudyStatus.StudyStatusName == sm.StudyStatus && status.GroupID == presentgroup)
                                         select status.LocalStudyStatus.StudyStatusName).FirstOrDefault <string>();
                        if (newStatus != null)
                        {
                            std.StudyName      = sm.StudyName;
                            std.StudyCode      = sm.StudyCode;
                            std.StudyID        = sm.StudyID;
                            std.SponsorName    = sm.Sponsor.SponsorName;
                            std.StudyStartDate = sm.StudyStartDate;
                            std.Status         = newStatus;
                            grant.studymodel.Add(std);
                        }
                    }

                    if (SearchText != null && SearchText != "")
                    {
                        List <StudyModels>   searchStudyList      = grant.studymodel.Where(x => x.StudyName.ToLower().Contains(SearchText.ToLower())).ToList <StudyModels>();
                        GrantDenyStudyModels grantDenyStudyModels = new GrantDenyStudyModels();
                        grantDenyStudyModels.studymodel = searchStudyList;
                        return(View(grantDenyStudyModels));
                    }
                    return(View(grant));
                }
            }
            catch (NullReferenceException ex)
            {
                return(Redirect(FormsAuthentication.LoginUrl));
            }
            catch (Exception e)
            {
                ViewBag.message = e.Message;
                return(View("Error"));
            }
        }
Exemplo n.º 2
0
        public ActionResult GetStudy()
        {
            try
            {
                if (pagemanager.IsPageValid((int)Session["BOGroupId"], 7))
                {
                    return(View("PageError"));
                }
                else
                {
                    int UserID = (int)Session["AccessUserId"];
                    var user   = usermanager.GetUserByID(UserID);

                    var studyperm = studymanager.GetStudiesByUserId(UserID);
                    GrantDenyStudyModel.studymodelDenied  = new List <StudyModel>();
                    GrantDenyStudyModel.studymodelGranted = new List <StudyModel>();
                    foreach (var item in studyperm)
                    {
                        StudyModel studymodel = new StudyModel();
                        Study      std        = new Study();
                        std = studymanager.GetStudyByStudyId(item.StudyID);
                        studymodel.StudyID   = std.StudyID;
                        studymodel.StudyName = std.StudyName;
                        studymodel.StudyCode = std.StudyCode;
                        Sponsor spnr = new Sponsor();
                        spnr = sponsormanager.GetSponsorById(item.SponsorID.ToString());
                        studymodel.SponsorName = spnr.SponsorName;
                        if (item.Status == true)
                        {
                            studymodel.Status   = item.Status;
                            studymodel.Selected = false;
                            GrantDenyStudyModel.studymodelGranted.Add(studymodel);
                        }
                        if (item.Status == false)
                        {
                            studymodel.Status   = item.Status;
                            studymodel.Selected = false;
                            GrantDenyStudyModel.studymodelDenied.Add(studymodel);
                        }
                    }

                    return(PartialView("_StudyList", GrantDenyStudyModel));
                }
            }
            catch (NullReferenceException ex)
            {
                return(Redirect(FormsAuthentication.LoginUrl));
            }
            catch (Exception e)
            {
                ViewBag.message = e.Message;
                return(View("Error"));
            }
        }