Example #1
0
        public HttpResponseMessage ListFollowAndFollowMeAndAttendeeAndPresenter(int personId, string userName, int conferenceId)
        {
            try
            {
                var followModel   = new FollowModel();
                var channelModel  = new ChannelModel();
                var listFollow    = followModel.getListFollow(userName, conferenceId);
                var listFollowMe  = followModel.getListFollowMe(userName, conferenceId);
                var listAttendee  = channelModel.getListAttendee(personId, conferenceId);
                var listPresenter = channelModel.getListPresenter(personId, conferenceId);

                //Lọc ra những tài khoản giống nhau
                var result = new ListForNewChannel();
                result.ListFollow    = listFollow;
                result.ListFollowMe  = listFollowMe;
                result.ListAttendee  = new List <Presenter>();
                result.ListPresenter = new List <Presenter>();

                foreach (Presenter attendee in listAttendee)
                {
                    if (result.ListFollow != null && result.ListFollowMe != null)
                    {
                        if (!result.ListFollow.Any(x => x.PERSON_ID == attendee.PERSON_ID) && !result.ListFollowMe.Any(x => x.PERSON_ID == attendee.PERSON_ID))
                        {
                            if (attendee.PERSON_ID != personId)
                            {
                                result.ListAttendee.Add(attendee);
                            }
                        }
                    }
                    else if (result.ListFollow != null && result.ListFollowMe == null)
                    {
                        if (!result.ListFollow.Any(x => x.PERSON_ID == attendee.PERSON_ID))
                        {
                            if (attendee.PERSON_ID != personId)
                            {
                                result.ListAttendee.Add(attendee);
                            }
                        }
                    }
                    else if (result.ListFollow == null && result.ListFollowMe != null)
                    {
                        if (!result.ListFollowMe.Any(x => x.PERSON_ID == attendee.PERSON_ID))
                        {
                            if (attendee.PERSON_ID != personId)
                            {
                                result.ListAttendee.Add(attendee);
                            }
                        }
                    }
                }

                foreach (Presenter presenter in listPresenter)
                {
                    if (result.ListFollow != null && result.ListFollowMe != null)
                    {
                        if (!result.ListFollow.Any(x => x.PERSON_ID == presenter.PERSON_ID) && !result.ListFollowMe.Any(x => x.PERSON_ID == presenter.PERSON_ID))
                        {
                            if (presenter.PERSON_ID != personId)
                            {
                                result.ListPresenter.Add(presenter);
                            }
                        }
                    }
                    else if (result.ListFollow != null && result.ListFollowMe == null)
                    {
                        if (!result.ListFollow.Any(x => x.PERSON_ID == presenter.PERSON_ID))
                        {
                            if (presenter.PERSON_ID != personId)
                            {
                                result.ListPresenter.Add(presenter);
                            }
                        }
                    }
                    else if (result.ListFollow == null && result.ListFollowMe != null)
                    {
                        if (!result.ListFollowMe.Any(x => x.PERSON_ID == presenter.PERSON_ID))
                        {
                            if (presenter.PERSON_ID != personId)
                            {
                                result.ListPresenter.Add(presenter);
                            }
                        }
                    }
                }

                return(ResponseSuccess(StringResource.Success, result));
            }
            catch
            {
                return(ResponseFail(StringResource.Get_list_for_new_channel_error));
            }
        }