Ejemplo n.º 1
0
        public ActionResult DeleteResearchgroup(int rcaid)
        {
            ResearchgroupCohortAssignment rca = db.ResearchgroupCohortAssignments.Find(rcaid);

            if (rca == null)
            {
                return(new HttpStatusCodeResult(422));
            }
            if (rca.Status != "Current")
            {
                return(new HttpStatusCodeResult(422));
            }

            if (!_projectuservalidationservice.UserCanEditProject(rca.Cohorts.MultiPARTProjectMultiPARTProjectID))
            {
                ViewBag.ErrorMessage = "Access Denied. Please contact administrator for further assistance.";
                return(View("Error"));
            }

            rca.Status        = "Deleted";
            rca.LastUpdatedBy = (int)Membership.GetUser().ProviderUserKey;

            db.SaveChanges();

            return(RedirectToAction("IndexResearchgroup", new { cohortid = rca.CohortID }));
        }
Ejemplo n.º 2
0
        public ActionResult AddResearchgroup(ResearchgroupCohortAssignmentViewModel rcaVM)
        {
            if (!ModelState.IsValid || rcaVM == null)
            {
                return(new HttpStatusCodeResult(422));
            }

            if (!_projectuservalidationservice.UserCanEditProject(rcaVM.MultiPARTProjectID))
            {
                ViewBag.ErrorMessage = "Access Denied. Please contact administrator for further assistance.";
                return(View("Error"));
            }

            ResearchgroupCohortAssignment rca = new ResearchgroupCohortAssignment()
            {
                ResearchgroupID = rcaVM.ResearchgroupID,
                NumberOfAnimals = rcaVM.NumberOfAnimals,
                CohortID        = rcaVM.CohortID,

                LastUpdatedBy = (int)Membership.GetUser().ProviderUserKey,
                CreatedBy     = (int)Membership.GetUser().ProviderUserKey,
            };

            db.ResearchgroupCohortAssignments.Add(rca);

            db.SaveChanges();
            return(RedirectToAction("IndexResearchgroup", new { cohortid = rcaVM.CohortID }));
        }
Ejemplo n.º 3
0
        //
        // GET: /Cohort/Details/5

        public ActionResult EditResearchgroup(int rcaid)
        {
            ResearchgroupCohortAssignment rca = db.ResearchgroupCohortAssignments.Find(rcaid);

            if (rca == null)
            {
                return(new HttpStatusCodeResult(422));
            }
            if (rca.Status != "Current")
            {
                return(new HttpStatusCodeResult(422));
            }

            if (!_projectuservalidationservice.UserCanEditProject(rca.Cohorts.MultiPARTProjectMultiPARTProjectID))
            {
                ViewBag.ErrorMessage = "Access Denied. Please contact administrator for further assistance.";
                return(View("Error"));
            }

            ViewBag.ResearchgroupList = new SelectList(
                db.Researchgroups.Where(r => db.ResearchgroupInMultiPARTProjects.Where(rm => rm.Status == "Current" &&
                                                                                       rm.MultiPARTProjectMultiPARTProjectID == rca.Cohorts.MultiPARTProjectMultiPARTProjectID &&
                                                                                       rm.Options.OptionValue == "Wet Lab").Select(rm => rm.ResearchgroupResearchgroupID).Contains(r.ResearchgroupID)).AsEnumerable(),
                "ResearchgroupID", "ResearchgroupName", rca.ResearchgroupID);

            ViewBag.cohortid = rca.CohortID;

            ResearchgroupCohortAssignmentViewModel rcaVM = new ResearchgroupCohortAssignmentViewModel()
            {
                CohortID           = rca.CohortID,
                MultiPARTProjectID = rca.Cohorts.MultiPARTProjectMultiPARTProjectID,
                ResearchgroupID    = rca.ResearchgroupID,
                ResearchgroupName  = rca.Researchgroups.ResearchgroupName,
                NumberOfAnimals    = rca.NumberOfAnimals,
                ResearchgroupCohortAssignmentID = rca.ResearchgroupCohortAssignmentID,
            };

            ViewBag.MultiPARTProjectID = rca.Cohorts.MultiPARTProjectMultiPARTProjectID;

            return(View(rcaVM));
        }