GetAllReviewer() public method

Return all reviewer
public GetAllReviewer ( ) : ReviewerEntity>.IDictionary
return ReviewerEntity>.IDictionary
Example #1
0
        public static string SetReviewer(string reviewerName, string affiliation)
        {
            string reviewerKey = string.Empty;
            try
            {
                #region Add Reviewer In DB
                TableManager tblMgr = new TableManager();
                ReviewerEntity reviewer = new ReviewerEntity();

                bool isReviewerAlreadyPresent = false;

                var reviewers = tblMgr.GetAllReviewer();

                for (int rid = 0; rid < reviewers.Keys.Count; rid++)
                {
                    string key = reviewers.ElementAt(rid).Key;
                    if (reviewers[key].ReviewerName.Trim() == reviewerName.Trim())
                    {
                        isReviewerAlreadyPresent = true;
                        reviewerKey = key;
                        break;
                    }
                }

                if (!isReviewerAlreadyPresent)
                {
                    reviewer.RowKey = reviewer.ReviewerId = Guid.NewGuid().ToString();
                    reviewer.ReviewerName = reviewerName.Trim();
                    reviewer.Affilation = affiliation.Trim();
                    reviewer.ReviewerImage = string.Empty;
                    tblMgr.UpdateReviewerById(reviewer);

                    reviewerKey = reviewer.ReviewerId;
                }
                #endregion
            }
            catch (Exception)
            {
            }

            return reviewerKey;
        }
        // get : api/Movies?type={current/all (default)}&resultlimit={default 100}
        protected override string ProcessRequest()
        {
            int resultLimit = 15;

            // get query string parameters
            string queryParameters = this.Request.RequestUri.Query;
            if (queryParameters != null)
            {
                var tableMgr = new TableManager();
                var qpParams = HttpUtility.ParseQueryString(queryParameters);

                string reviewerInitials = string.Empty;

                if (!string.IsNullOrEmpty(qpParams["q"]))
                {
                    reviewerInitials = qpParams["q"].ToString().ToLower();
                }

                var artistsByName = tableMgr.GetAllReviewer(reviewerInitials.ToLower()).Take(resultLimit).ToList().OrderBy(a => a.ReviewerName);
                return jsonSerializer.Value.Serialize(artistsByName);
            }

            return string.Empty;
        }