Ejemplo n.º 1
0
        public void Add()
        {
            var tag = new ArticleTag()
            {
                Description  = "Test data",
                Name         = "Test",
                ModifiedById = null,
                CompanyId    = 1,
                Resources    = new List <ArticleTagResource>
                {
                    new ArticleTagResource {
                        Culture = Culture.English, Value = "Test"
                    },
                    new ArticleTagResource {
                        Culture = Culture.Spanish, Value = "Prueba"
                    },
                    new ArticleTagResource {
                        Culture = Culture.Hindi, Value = "pareekshan"
                    }
                }
            };
            var result = _tagService.Add(tag);

            Assert.IsNotNull(result);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Add(TagsAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemResponse <int> response = new ItemResponse <int>();

            string userId = UserService.GetCurrentUserId();

            response.Item = _tagsService.Add(model, userId);

            return(Request.CreateResponse(response));
        }
Ejemplo n.º 3
0
        public IActionResult Tag(int id, AddTagModel newTag)
        {
            int userId = int.Parse(HttpContext.User.FindFirstValue("Id"));

            string[] tagNames = newTag.Tags.Split(',').Select(x => x.Trim()).ToArray();
            int[]    tagIds   = _tagsService.Add(tagNames).ToArray();
            try
            {
                _questionsTagsService.Add(userId, id, tagIds);
            }
            catch (AskMateNotAuthorizedException)
            {
                return(Forbid());
            }
            return(RedirectToAction("Details", new { id }));
        }
Ejemplo n.º 4
0
        public ActionResult Save([DataSourceRequest] DataSourceRequest dsRequest, Tags tag)
        {
            var tagDetails = _tagsService.GetTagsDetails().Where(model => model.TagName == tag.TagName && model.TagId != tag.TagId);

            if (tagDetails.Count() > 0)
            {
                ModelState.AddModelError(string.Empty, "The Tag already exists, please create with other name.");
            }
            if (tag != null && ModelState.IsValid)
            {
                tag.IsActive    = true;
                tag.Description = HttpUtility.HtmlDecode(tag.Description);
                _tagsService.Add(tag);
                //TempData.Add("IsNewTag", 1);
                return(Json(tag));
            }
            //tag.Description = HttpUtility.HtmlDecode(tag.Description);
            //return View("Add", tag);
            return(Json(ModelState.ToDataSourceResult()));
        }
Ejemplo n.º 5
0
        public JsonResult AddOrUpdate(TagDTO model)
        {
            var status = false;

            if (ModelState.IsValid)
            {
                Tag tag = new Tag();
                tag.ID     = model.ID;
                tag.Name   = model.Name;
                tag.Detail = model.Detail;

                if (model.ID == 0)
                {
                    status = tagService.Add(tag);
                }
                else
                {
                    status = tagService.Update(tag);
                }
                tagService.Save();
            }
            return(Json(status, JsonRequestBehavior.AllowGet));
        }