public IHttpActionResult GetName(dynamic usersId)
        {
            if (!Common.GetAuthorization(Request))
            {
                return(Ok(new { Code = 401, Message = "Unauthorization" }));
            }

            var user = _userBusinessService.GetByToken(Request.Headers.GetValues("AccessToken").First());

            if (user != null)
            {
                _webStatus.code        = 200;
                _webStatus.description = "Success";

                List <TicketTagsAPI> listName = new List <TicketTagsAPI>();
                if (usersId != null)
                {
                    foreach (int userId in usersId)
                    {
                        TicketTagsAPI userObj = new TicketTagsAPI()
                        {
                            Name = _userBusinessService.GetDetail(userId).Name
                        };
                        listName.Add(userObj);
                    }

                    return(Ok(new { status = _webStatus, data = listName }));
                }

                _webStatus.code        = 400;
                _webStatus.description = "Empty parameter";
                return(Ok(new { status = _webStatus, data = new object() }));
            }
            else
            {
                _webStatus.code        = 403;
                _webStatus.description = "Invalid AccessToken";

                return(Ok(_webStatus));
            }
        }
Ejemplo n.º 2
0
        private void UpdateArticleTags(string tags, int artikelId)
        {
            string[] tagsArray   = tags.Split(',');
            var      currentTags = _articleTagsService.GetTagsByArticle(artikelId);

            if (currentTags != null)
            {
                List <TicketTagsAPI> listCurrentTagApi = new List <TicketTagsAPI>();
                foreach (var currentTag in currentTags)
                {
                    TicketTagsAPI tagApi = new TicketTagsAPI {
                        Name = currentTag.Name
                    };
                    listCurrentTagApi.Add(tagApi);
                }

                foreach (var currentTagApi in listCurrentTagApi)
                {
                    if (!tags.Any(currentTagApi.Name.Contains))
                    {
                        _articleTagsService.Delete(artikelId, currentTagApi.Name);
                    }
                }
            }

            ArticleTags articleTag = new ArticleTags();

            for (int i = 0, iLen = tagsArray.Length; i < iLen; i++)
            {
                if (!_articleTagsService.IsThisTagExists(artikelId, tagsArray[i]))
                {
                    articleTag.Name      = tagsArray[i];
                    articleTag.ArticleId = artikelId;

                    _articleTagsService.Add(articleTag);
                }
            }
        }