Beispiel #1
0
        public ActionResult <ItemResponse <InstagramToken> > GetInfluencer(int userId)
        {
            ItemResponse <InstagramToken> response = null;
            ActionResult result = null;

            try
            {
                InstagramToken token = _instagramService.Get(userId);

                if (token == null)
                {
                    result = NotFound404(new ErrorResponse("Doesn't Exist"));
                }
                else
                {
                    response      = new ItemResponse <InstagramToken>();
                    response.Item = token;
                    result        = Ok200(response);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());

                result = StatusCode(500, new ErrorResponse(ex.Message));
            }
            return(result);
        }
        private InstagramToken Mapper(IDataReader reader)
        {
            int            index = 0;
            InstagramToken token = new InstagramToken();

            token.Id          = reader.GetSafeInt32(index++);
            token.UserId      = reader.GetSafeInt32(index++);
            token.AccessToken = reader.GetSafeString(index++);

            return(token);
        }
        public InstagramToken Get(int userId)
        {
            InstagramToken token = null;

            _dataProvider.ExecuteCmd(
                "dbo.InstagramSelectAccessToken",
                (parameters) =>
            {
                parameters.AddWithValue("@UserId", userId);
            },
                (reader, recordSetIndex) =>
            {
                token = Mapper(reader);
            }
                );
            return(token);
        }