public IActionResult Load(Int64?groupID, Int64?langId)
        {
            GetGroups operation = new GetGroups();

            operation.ID = groupID;

            if (langId.HasValue)
            {
                operation.LangID = langId;
            }
            else
            {
                operation.LangID = 1;
            }

            var result = operation.QueryAsync().Result;

            if (result is ValidationsOutput)
            {
                return(Ok(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                }));
            }
            else
            {
                return(Ok((List <Group>)result));
            }
        }
Beispiel #2
0
        private void GotFullChunks(MessageType messageType, TcpClient client, List <byte[]> receivedChunks)
        {
            //1. Client send Login Try
            //2. Client asks for a groups
            //3. Client asks for a tests
            //4. Client send result
            switch (messageType)
            {
            case MessageType.ClientLoginTry:
            {
                var val = receivedChunks.CombineChunksInto <User>();
                LogTry?.Invoke(val, client);
                break;
            }

            case MessageType.ClientRequestGroups:
            {
                var val = receivedChunks.CombineChunksInto <User>();
                GetGroups?.Invoke(val, client);
                break;
            }

            case MessageType.ClientRequestTests:
            {
                //Group id
                var val = receivedChunks.CombineChunksInto <int>();
                GetTests?.Invoke(val, client);
                break;
            }

            case MessageType.ClientSendResult:
            {
                var val = receivedChunks.CombineChunksInto <Result>();
                ResultSend?.Invoke(val, client);
                break;
            }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Get list of groups
        /// </summary>
        /// <param name="request">Request.</param>
        public object Get(GetGroups request)
        {
            List <WebGroup> result = new List <WebGroup>();

            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            try {
                context.Open();
                context.LogInfo(this, string.Format("/group GET"));
                EntityList <Group> grps = new EntityList <Group>(context);
                grps.Load();
                foreach (Group g in grps)
                {
                    result.Add(new WebGroup(g));
                }

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(result);
        }
        public IActionResult Load(Int64?ID, Int64?userID, Int64?langId)
        {
            GetUserGroups operation = new GetUserGroups();


            if (langId.HasValue)
            {
                operation.LangID = langId;
            }
            else
            {
                operation.LangID = 1;
            }
            if (!userID.HasValue)
            {
                operation.ID = ID;
                var results = operation.QueryAsync().Result;
                return(Ok((List <UserGroup>)results));
            }
            operation.UserID = userID;
            var       result     = operation.QueryAsync().Result;
            var       userGroups = (List <UserGroup>)result;
            GetGroups groups     = new GetGroups();

            groups.LangID = 1;
            if (langId.HasValue)
            {
                groups.LangID = langId;
            }
            else
            {
                groups.LangID = 1;
            }
            var          Groups = (List <Group>)groups.QueryAsync().Result;
            List <Group> returnedRelatedGroups   = new List <Group>();
            List <Group> returnedUnRelatedGroups = new List <Group>();

            if (userGroups.Count > 0)
            {
                foreach (var group in Groups)
                {
                    foreach (var item in userGroups)
                    {
                        if (group.ID == item.RefrenceID)
                        {
                            bool alreadyExist             = returnedRelatedGroups.Contains(group);
                            bool alreadyExistInSecondList = returnedUnRelatedGroups.Contains(group);
                            if (!alreadyExist && !alreadyExistInSecondList)
                            {
                                group.UserRelationID = item.ID;
                                returnedRelatedGroups.Add(group);
                            }
                            else
                            {
                                group.UserRelationID = item.ID;
                                returnedRelatedGroups.Add(group);
                                returnedUnRelatedGroups.Remove(group);
                            }
                        }
                        else
                        {
                            bool alreadyExist            = returnedUnRelatedGroups.Contains(group);
                            bool alreadyExistInFirstList = returnedRelatedGroups.Contains(group);
                            if (!alreadyExist && !alreadyExistInFirstList)
                            {
                                group.UserRelationID = item.ID;
                                returnedUnRelatedGroups.Add(group);
                            }
                        }
                    }
                }
            }
            else
            {
                returnedUnRelatedGroups = Groups;
            }


            if (result is ValidationsOutput)
            {
                return(Ok(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                }));
            }
            else
            {
                return(Ok(new { RelatedGroups = returnedRelatedGroups, UnRelatedGroups = returnedUnRelatedGroups }));
            }
        }
Beispiel #5
0
        /// <summary>
        /// get book types
        /// </summary>
        /// <returns></returns>
        public List <BookTypeGroup> getBookTypeGroup()
        {
            GetGroups g = new GetGroups();

            return(g.getBookTypeGroup());
        }
Beispiel #6
0
        /// <summary>
        /// get profession news by collegeID
        /// </summary>
        /// <param name="collegeID"></param>
        /// <returns></returns>
        public List <ProfessionGroup> getProfessionGroup(string collegeID)
        {
            GetGroups group = new GetGroups();

            return(group.getProfessionGroup(collegeID));
        }
Beispiel #7
0
        /// <summary>
        /// get college news by schoolID
        /// </summary>
        /// <returns></returns>
        public List <CollegeGroup> getCollegeGroup(string schoolID)
        {
            GetGroups group = new GetGroups();

            return(group.getCollegeGroup(schoolID));
        }
Beispiel #8
0
        /// <summary>
        /// get all school news
        /// </summary>
        /// <returns></returns>
        public List <SchoolGroup> getSchoolGroup()
        {
            GetGroups group = new GetGroups();

            return(group.getSchoolGroup());
        }
Beispiel #9
0
        public List <ProfessionGroup> getProfessionName(string collegeID)
        {
            GetGroups dal = new GetGroups();

            return(dal.getProfessionGroup(collegeID));
        }
Beispiel #10
0
        //public List<CollegeGroup> getCollegeName(string schoolID)
        //{
        //    GetGroups dal = new GetGroups();
        //    return dal.getCollegeGroup(schoolID);
        //}
        public List <CollegeGroup> getCollegeName(string schoolID)
        {
            GetGroups dal = new GetGroups();

            return(dal.getCollegeGroup(schoolID));
        }
Beispiel #11
0
        public List <SchoolGroup> getSchoolName()
        {
            GetGroups dal = new GetGroups();

            return(dal.getSchoolGroup());
        }