Beispiel #1
0
        /// <summary>
        /// Gets a User by PublicKey
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public API_User GetSpecificUser(string id)
        {
            var usr = _dataAccess.User_GetUser(id);
            if (usr == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            // API_User object
            var apiUser = new API_User();
            apiUser = apiUser.ConvertToAPI_UserWithAssociatedLists(usr);

            var apiListShare = new API_ListShare();
            // Get ListShares they own
            foreach (var ols in _dataAccess.ListShare_GetAllListSharesForOwner(apiUser.PublicKey))
            {
                apiUser.OwnedListShares.Add(apiListShare.ConvertToAPI_ListShareWithoutAssociatedList(ols));
            }

            // Get ListShares they consume
            foreach (var cls in _dataAccess.ListShare_GetAllListSharesForConsumer(apiUser.PublicKey))
            {
                apiUser.ConsumedListShares.Add(apiListShare.ConvertToAPI_ListShareWithoutAssociatedList(cls));
            }

            return apiUser;
        }
Beispiel #2
0
        public API_List GetList(string id)
        {
            var usrList = _dataAccess.List_GetListByPublicKey(id);
            API_List rcUsrList = new API_List(); ;
            API_ListShare listShare = new API_ListShare();
            if (usrList == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            else
            {
                rcUsrList = rcUsrList.ConvertToAPI_ListWithActiveItems(usrList);
            }

            // Add the associated ListShares
            foreach (var ls in _dataAccess.ListShare_GetAllByListPublicKey(id))
            {
                rcUsrList.ListShares.Add(listShare.ConvertToAPI_ListShareWithoutAssociatedList(ls));
            }

            return rcUsrList;
        }