Example #1
0
        public async Task <HttpResponseMessage> GetFromCommunity(int id, string type = "member")
        {
            IStateFactory <userInfo, UsersCollectionState> _stateFactory = new UsersCollectionFactory(new UserLinkFactory(Request));
            var instance = UserService.GetInstance();

            OperationResult <IEnumerable <userInfo> > users = null;

            if (type == "member")
            {
                users = await instance.GetUserFromCommunityByRole(id, Services.Models.Roles.Role.Member);
            }
            else if (type == "admin")
            {
                users = await instance.GetUserFromCommunityByRole(id, Services.Models.Roles.Role.Admin);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new BadRequest(Request.RequestUri, "The values of query string must be 'member' or 'admin"), "application/problem+json"));
            }

            if (users.Success)
            {
                var res = users.Result.Select <userInfo, UsersCollectionState>(i => _stateFactory.Create(i));
                return(Request.CreateResponse(HttpStatusCode.OK, new { users = res }, "application/json"));
            }
            return(Request.CreateResponse(HttpStatusCode.NotFound, new NotFound(Request.RequestUri, users.Message), "application/problem+json"));
        }
Example #2
0
        public async Task <HttpResponseMessage> GetFromEvent(int id, string isCheckedIn = "false")
        {
            IStateFactory <userInfo, UsersCollectionState> _stateFactory = new UsersCollectionFactory(new UserLinkFactory(Request));
            var instance = UserService.GetInstance();

            OperationResult <IEnumerable <userInfo> > users = null;

            if (isCheckedIn == "false")
            {
                users = await instance.GetUsersSubscribedOnEvent(id, Services.Services.UserService.Check_in.False);
            }
            else if (isCheckedIn == "true")
            {
                users = await instance.GetUsersSubscribedOnEvent(id, Services.Services.UserService.Check_in.True);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, new BadRequest(Request.RequestUri, "The values of query string must be 'true' or 'false"), "application/problem+json"));
            }

            if (users.Success)
            {
                var res = users.Result.Select <userInfo, UsersCollectionState>(i => _stateFactory.Create(i));
                return(Request.CreateResponse(HttpStatusCode.OK, new { users = res }, "application/json"));
            }
            return(Request.CreateResponse(HttpStatusCode.NotFound, new NotFound(Request.RequestUri, users.Message), "application/problem+json"));
        }
 public CommunitySingleFactory(HttpRequestMessage request)
 {
     _links         = new CommunityLinkFactory(request);
     eventFactory   = new EventsCollectionFactory(new EventLinkFactory(request));
     noticeFactory  = new NoticesCollectionFactory(new NoticeLinkFactory(request));
     userFactory    = new UsersCollectionFactory(new UserLinkFactory(request));
     commentFactory = new CommentsCollectionFactory(request);
 }
Example #4
0
 public EventSingleFactory(HttpRequestMessage request)
 {
     _links           = new EventLinkFactory(request);
     communityFactory = new CommunitiesCollectionFactory(new CommunityLinkFactory(request));
     userFactory      = new UsersCollectionFactory(new UserLinkFactory(request));
     sessionFactory   = new SessionsCollectionFactory(new SessionLinkFactory(request));
     commentFactory   = new CommentsCollectionFactory(request);
     surveyFactory    = new SurveySingleFactory(request);
 }
Example #5
0
        public async Task <HttpResponseMessage> Get()
        {
            IStateFactory <userInfo, UsersCollectionState> _stateFactory = new UsersCollectionFactory(new UserLinkFactory(Request));
            var instance = UserService.GetInstance();

            var users = await instance.GetAllAsync();

            if (users.Success)
            {
                var res = users.Result.Select <userInfo, UsersCollectionState>(i => _stateFactory.Create(i));
                return(Request.CreateResponse(HttpStatusCode.OK, new { users = res }, "application/json"));
            }
            return(Request.CreateResponse(HttpStatusCode.ServiceUnavailable, new ServiceUnvailable(Request.RequestUri, users.Message), "application/problem+json"));
        }