Exemple #1
0
        public bool SaveParticipantCallerMapping(ParticipantCallerMapping participantCallerMapping, out string message)
        {
            message = string.Empty;
            bool result = false;

            using (var unitOfWork = CreateUnitOfWork())
            {
                var toupdate = unitOfWork.ParticipantCallerMappings.Get(participantCallerMapping.ParticipantCallerMappingID);

                if (toupdate == null)
                {
                    message = "ParticipantCallerMapping Not found";
                    result  = false;
                }

                else
                {
                    toupdate.PhaseIFollowUpVolunteerCallRemark   = participantCallerMapping.PhaseIFollowUpVolunteerCallRemark;
                    toupdate.PhaseIFollowUpVolunteerCallDateTime = participantCallerMapping.PhaseIFollowUpVolunteerCallDateTime;
                    toupdate.PhaseIFollowUpVolunteerCallStatus   = participantCallerMapping.PhaseIFollowUpVolunteerCallStatus;

                    toupdate.PhaseIIFollowUpVolunteerCallRemark   = participantCallerMapping.PhaseIIFollowUpVolunteerCallRemark;
                    toupdate.PhaseIIFollowUpVolunteerCallDateTime = participantCallerMapping.PhaseIIFollowUpVolunteerCallDateTime;
                    toupdate.PhaseIIFollowUpVolunteerCallStatus   = participantCallerMapping.PhaseIIFollowUpVolunteerCallStatus;

                    //toupdate.PhaseICommitteeMember = participantCallerMapping.PhaseICommitteeMember;
                    toupdate.PhaseICommitteeMemberCallRemark   = participantCallerMapping.PhaseICommitteeMemberCallRemark;
                    toupdate.PhaseICommitteeMemberCallDateTime = participantCallerMapping.PhaseICommitteeMemberCallDateTime;
                    toupdate.PhaseICommitteeMemberCallStatus   = participantCallerMapping.PhaseICommitteeMemberCallStatus;

                    //toupdate.PhaseIICommitteeMember = participantCallerMapping.PhaseIICommitteeMember;
                    toupdate.PhaseIICommitteeMemberCallRemark   = participantCallerMapping.PhaseIICommitteeMemberCallRemark;
                    toupdate.PhaseIICommitteeMemberCallDateTime = participantCallerMapping.PhaseIICommitteeMemberCallDateTime;
                    toupdate.PhaseIICommitteeMemberCallStatus   = participantCallerMapping.PhaseIICommitteeMemberCallStatus;

                    using (TransactionScope scope = new TransactionScope())
                    {
                        unitOfWork.Complete();
                        scope.Complete();
                        result = true;
                    }
                }
            }

            return(result);
        }
Exemple #2
0
        public ActionResult SaveParticipantCallerMapping([Bind(Exclude = "ParticipantID,FollowUpGroupID,PhaseIFollowUpVolunteer,PhaseIIFollowUpVolunteer,PhaseICommitteeMember,PhaseIICommitteeMember")] ParticipantCallerMapping participantCallerMapping)
        {
            string message = string.Empty;

            using (var followUpManager = new FollowUpManager())
            {
                bool isSaved = followUpManager.SaveParticipantCallerMapping(participantCallerMapping, out message);

                if (!isSaved)
                {
                    return(Json(new { success = false, error = message, isautosave = false }));
                }

                else
                {
                    return(Json(new { success = true, message = "Your changes were saved.", isautosave = false }));
                }
            }
        }
Exemple #3
0
        public IList <FollowUpGroup> GetParticipantsByFollowUpConfiguration(int followupconfigurationid, out string message)
        {
            message = string.Empty;
            var result         = new List <FollowUpGroup>();
            var followupconfig = GetFollowUpConfiguration(followupconfigurationid);

            if (followupconfig == null)
            {
                message = "Follow-up configuration does not exist!";
                return(result);
            }

            if (followupconfig.Deploy)
            {
                result = followupconfig.FollowUpGroups.ToList();
                return(result);
            }

            var followupgroups = followupconfig.FollowUpGroups;

            if (followupgroups.Count <= 0)
            {
                message = "No follow-up groups found.";
                return(result);
            }

            var eventid = followupconfig.PHSEventID;
            var finalgroupparticipants = GetAllParticipants(eventid);

            foreach (var item in followupgroups)
            {
                using (var unitOfWork = CreateUnitOfWork())
                {
                    var participantCallerMappingList = new List <ParticipantCallerMapping>();
                    //testing
                    //var participantsbygroup = unitOfWork.Participants.FindParticipants(p => p.Language == "Mandarin" && p.PHSEvents.Any(e => e.PHSEventID == eventid));

                    /*BMI : "3#19#35#36#470#==#25.0"*/ /*"BP : 3#19#35#36#466#==#100"*/
                    var participantsbygroup = unitOfWork.Participants.SearchParticipants(item.Filter).ToList();
                    //var participantsbygroup = SearchParticipants(item.Filter);

                    //avoid overlapping participants
                    var intersectresult = finalgroupparticipants.Where(a => participantsbygroup.Select(b => b.ParticipantID).Contains(a.ParticipantID)).ToList();
                    participantsbygroup = intersectresult;
                    var exceptresult = finalgroupparticipants.Where(a => !participantsbygroup.Select(b => b.ParticipantID).Contains(a.ParticipantID)).ToList();
                    finalgroupparticipants = exceptresult;

                    foreach (var participant in participantsbygroup)
                    {
                        var participantcallermapping = new ParticipantCallerMapping();
                        participantcallermapping.Participant = participant;
                        participantCallerMappingList.Add(participantcallermapping);
                    }
                    item.ParticipantCallerMappings = participantCallerMappingList;
                    result.Add(item);
                }
            }
            var endfugroup = new FollowUpGroup();
            var endparticipantCallerMappingList = new List <ParticipantCallerMapping>();

            foreach (var participant in finalgroupparticipants.ToList())
            {
                var endparticipantcallermapping = new ParticipantCallerMapping();
                endparticipantcallermapping.Participant = participant;
                endparticipantCallerMappingList.Add(endparticipantcallermapping);
            }
            endfugroup.Title = "No Group Participants";
            endfugroup.ParticipantCallerMappings = endparticipantCallerMappingList;
            result.Add(endfugroup);

            return(result);
        }
Exemple #4
0
        public bool DeployFollowUpConfiguration(int followupconfigurationid, out string message)
        {
            message = string.Empty;
            var result = new List <FollowUpGroup>();
            var followupconfiguration = GetFollowUpConfiguration(followupconfigurationid);

            if (followupconfiguration == null)
            {
                message = "No follow-up configuration found.";
                return(false);
            }

            if (followupconfiguration.Deploy)
            {
                message = "Follow-up configuration is already deployed!";
                return(false);
            }

            var followupgroups = followupconfiguration.FollowUpGroups;

            if (followupgroups.Count() <= 0)
            {
                message = "No follow-up groups found.";
                return(false);
            }

            using (var unitOfWork = CreateUnitOfWork())
            {
                var modelToUpdate = unitOfWork.FollowUpConfigurations.GetFollowUpConfiguration(followupconfigurationid);
                modelToUpdate.Deploy = true;
                //modelToUpdate.DateTime = DateTime.Now;

                var finalgroupparticipants = GetAllParticipants(followupconfiguration.PHSEventID);
                foreach (var item in followupgroups)
                {
                    //var participantsbygroup = unitOfWork.Participants.FindParticipants(p => p.Language == "Mandarin" && p.PHSEvents.Any(e => e.PHSEventID == eventid));
                    //var participantsbygroup = SearchParticipants(item.Filter);
                    var participantsbygroup = unitOfWork.Participants.SearchParticipants(item.Filter /*"3#19#35#36#470#==#25.0"*/).ToList();

                    //avoid overlapping participants
                    var intersectresult = finalgroupparticipants.Where(a => participantsbygroup.Select(b => b.ParticipantID).Contains(a.ParticipantID)).ToList();
                    participantsbygroup = intersectresult;
                    var exceptresult = finalgroupparticipants.Where(a => !participantsbygroup.Select(b => b.ParticipantID).Contains(a.ParticipantID)).ToList();
                    finalgroupparticipants = exceptresult;

                    foreach (var participant in participantsbygroup)
                    {
                        var participantcallermapping = new ParticipantCallerMapping();
                        participantcallermapping.FollowUpGroupID = item.FollowUpGroupID;
                        participantcallermapping.ParticipantID   = participant.ParticipantID;
                        unitOfWork.ParticipantCallerMappings.Add(participantcallermapping);
                    }
                }

                using (TransactionScope scope = new TransactionScope())
                {
                    unitOfWork.Complete();
                    scope.Complete();
                }
            }

            //var endfugroup = new FollowUpGroup();
            //foreach (var participant in finalgroupparticipants.ToList())
            //{
            //    var endparticipantcallermapping = new ParticipantCallerMapping();
            //    endparticipantcallermapping.Participant = participant;

            //}
            return(true);
        }