Пример #1
0
        private static List <string> GetAssignedForms(OSELS_EWEEntities Context, User CurrentUser)
        {
            List <string> Assigned = new List <string>();
            IQueryable <SurveyMetaData> AllForms = Context.SurveyMetaDatas.Where(x => x.ParentId == null &&
                                                                                 x.Users.Any(r => r.UserID == CurrentUser.UserID)
                                                                                 ).Distinct();
            string temp = AllForms.Count().ToString();

            foreach (var form in AllForms)
            {
                if (form.Users.Contains(CurrentUser) && form.ParentId == null)
                {
                    Assigned.Add(form.SurveyId.ToString());
                }
            }
            return(Assigned);
        }
Пример #2
0
        private static List <KeyValuePair <int, string> > GetSharedForms(int CurrentOrgId, OSELS_EWEEntities Context)
        {
            List <KeyValuePair <int, string> > Shared    = new List <KeyValuePair <int, string> >();
            IQueryable <SurveyMetaData>        AllForms1 = Context.SurveyMetaDatas.Where(x => x.ParentId == null &&
                                                                                         x.Organizations.Any(r => r.OrganizationId == CurrentOrgId)
                                                                                         ).Distinct();

            foreach (var form in AllForms1)
            {
                // checking if the form is shared with any organization
                SurveyMetaData Response = Context.SurveyMetaDatas.First(x => x.SurveyId == form.SurveyId);
                var            _Org     = new HashSet <int>(Response.Organizations.Select(x => x.OrganizationId));
                var            Orgs     = Context.Organizations.Where(t => _Org.Contains(t.OrganizationId)).ToList();
                //if form is shared
                if (Orgs.Count > 0)
                {
                    foreach (var org in Orgs)
                    {
                        KeyValuePair <int, string> Item = new KeyValuePair <int, string>(org.OrganizationId, form.SurveyId.ToString());

                        Shared.Add(Item);
                    }
                }
            }
            return(Shared);
        }