public bool ApplyForProject(int researcherId, int projectId)
        {
            using (ScheduleExEntities ctx = new ScheduleExEntities())
            {
                Project project = ctx.Projects.FirstOrDefault(p => p.ProjectId == projectId);
                User    user    = ctx.Users.FirstOrDefault(u => u.UserId == researcherId);

                int noOfMatches = project.Expertises.Select(ex => ex.ExpertiseId).ToList().Intersect(user.ResearcherExpertises.Select(ex => ex.ExpertiseId).ToList()).Count();

                string matchScore = string.Format("{0}/{1}", noOfMatches, project.Expertises.Count);

                if (ctx.ResearcherApprovals.Any(appr => appr.ResearcherId == researcherId && appr.ProjectId == projectId))
                {
                    return(false);
                }
                else
                {
                    ResearcherApproval ra = new ResearcherApproval();
                    ra.ApprovalStatusId     = Constants.APPROVAL_STS_APPLIED;
                    ra.ProjectId            = projectId;
                    ra.ResearcherId         = researcherId;
                    ra.HasResearcherApplied = true;
                    ra.ExpertiseMatchScore  = matchScore;
                    ctx.ResearcherApprovals.Add(ra);
                    ctx.SaveChanges();
                    return(true);
                }
            }
        }
Example #2
0
 public bool SaveInformationRequested(int availabilityId, int projectId, string informationRequested)
 {
     using (ScheduleExEntities ctx = new ScheduleExEntities())
     {
         ResearcherApproval approval = ctx.ResearcherApprovals.FirstOrDefault(ra => ra.ResearcherAvailabilityId == availabilityId && ra.ProjectId == projectId);
         approval.InfoRequested = informationRequested;
         ctx.SaveChanges();
         return(true);
     }
 }
 public bool SaveInformationRequested(int researcherId, int projectId, string informationRequested)
 {
     using (ScheduleExEntities ctx = new ScheduleExEntities())
     {
         ResearcherApproval approval = ctx.ResearcherApprovals.FirstOrDefault(ra => ra.ResearcherId == researcherId && ra.ProjectId == projectId);
         approval.InfoRequested    = informationRequested;
         approval.ApprovalStatusId = Constants.APPROVAL_STS_APPLIED;
         ctx.SaveChanges();
         return(true);
     }
 }
        public int AddResearcherAvailability(int researcherId, DateTime startDate, DateTime endDate)
        {
            using (ScheduleExEntities ctx = new ScheduleExEntities())
            {
                DataAccess.ResearcherAvailability ra = new DataAccess.ResearcherAvailability();
                ra.ResearcherId = researcherId;
                ra.StartDate    = startDate;
                ra.EndDate      = endDate;

                ctx.ResearcherAvailabilities.Add(ra);
                ctx.SaveChanges();
                return(ra.AvailabilityId);
            }
        }
Example #5
0
        public int AddResearcherExpertise(int researcherId, int expertiseId, string affilicatedOrgName)
        {
            using (ScheduleExEntities ctx = new ScheduleExEntities())
            {
                DataAccess.ResearcherExpertise re = new DataAccess.ResearcherExpertise();
                re.ResearcherId      = researcherId;
                re.ExpertiseId       = expertiseId;
                re.AffiliatedOrgName = affilicatedOrgName;

                ctx.ResearcherExpertises.Add(re);
                ctx.SaveChanges();
                return(re.ResearchExpertiseId);
            }
        }
 public bool DeleteResearcherAvailability(int availabilityId)
 {
     using (ScheduleExEntities ctx = new ScheduleExEntities())
     {
         DataAccess.ResearcherAvailability ra = ctx.ResearcherAvailabilities.FirstOrDefault(r => r.AvailabilityId == availabilityId);
         if (ra == null)
         {
             return(false);
         }
         else
         {
             ctx.ResearcherAvailabilities.Remove(ra);
             ctx.SaveChanges();
             return(true);
         }
     }
 }
Example #7
0
 public bool DeleteResearcherExpertise(int researcherExpertiseId)
 {
     using (ScheduleExEntities ctx = new ScheduleExEntities())
     {
         DataAccess.ResearcherExpertise re = ctx.ResearcherExpertises.FirstOrDefault(r => r.ResearchExpertiseId == researcherExpertiseId);
         if (re == null)
         {
             return(false);
         }
         else
         {
             ctx.ResearcherExpertises.Remove(re);
             ctx.SaveChanges();
             return(true);
         }
     }
 }
Example #8
0
 public bool ApplyForProject(int researcherAvailabilityId, int projectId)
 {
     using (ScheduleExEntities ctx = new ScheduleExEntities())
     {
         if (ctx.ResearcherApprovals.Any(appr => appr.ResearcherAvailabilityId == researcherAvailabilityId && (appr.ApprovalStatusId == Constants.APPROVAL_STS_APPROVED || appr.ApprovalStatusId == Constants.APPROVAL_STS_NEEDINFO || appr.ApprovalStatusId == Constants.APPROVAL_STS_BACKFORREV)))
         {
             return(false);
         }
         else
         {
             ResearcherApproval ra = new ResearcherApproval();
             ra.ApprovalStatusId         = Constants.APPROVAL_STS_NOT_STARTED;
             ra.ProjectId                = projectId;
             ra.ResearcherAvailabilityId = researcherAvailabilityId;
             ra.ResearcherId             = ctx.ResearcherAvailabilities.First(r => r.AvailabilityId == researcherAvailabilityId).ResearcherId;
             ctx.ResearcherApprovals.Add(ra);
             ctx.SaveChanges();
             return(true);
         }
     }
 }