public async Task CreateTag(string tagTitle) { //Check cache for existing tag in the future var tag = (ITag)container.GetService(typeof(ITag)); tag.Title = tagTitle; await tagRepository.CreateTag(tag); }
public IActionResult CreateTag([FromBody] TagRequest request) { try { var id = _tagRepository.CreateTag(request); return(Ok(id)); } catch (Exception) { return(BadRequest()); } }
public IActionResult CreateTag([FromBody] CreateTagViewModel model) { var user = userRepository.GetApplicationUserByUsername(User.Identity.Name, true); if (user == null) { return(Unauthorized()); } try { Tag tag = tagRepository.CreateTag(new Tag() { TagId = model.Name }); return(Ok(tag.TagId)); } catch (Exception) { return(BadRequest()); } }
public ActionResult Post([FromBody] Tag model) { try { // userName is not working ;/ var userName = this.User.Identity.Name; if (this.User.Identity.IsAuthenticated && userName != null) { // call repo here, pass model _tagRepository.CreateTag(model); return(Ok()); } else { return(this.StatusCode(StatusCodes.Status401Unauthorized, "Unauthorized request")); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public ActionResult Create(string instrName, string instrDescription, string[] stepName, string[] stepDescription, string tags, string[] imageUrl) { repositoryInstr.CreateInstr(instrName, instrDescription, _userManager.FindByNameAsync(User.Identity.Name).Result.Id); var instruction = context.Instructions.Where(x => x.Name == instrName).FirstOrDefault(); if (imageUrl.Length == 0) { imageUrl = new string[] { "", "", "", "" }; } if (tags.Length == 0) { tags = "Инструкции"; } foreach (var item in tags.Split(",")) { repositoryTag.CreateTag(item, instruction.InstructionId); } for (int i = 0; i < stepName.Length; i++) { repositoryStep.CreateStep(stepName[i], stepDescription[i], i.ToString(), instruction.InstructionId, imageUrl[i]); } return(Redirect("home/index")); }
internal void CreateTag(Tag tag) { _tagRepository.CreateTag(tag); _tagRepository.SaveChanges(); }
public void AddTags(string tags, int postId) { if (tags.Contains(',')) { var words = tags.Split(", ", StringSplitOptions.RemoveEmptyEntries); foreach (var item in words) { var tagId = tagRepository.FindTagByContent(item); if (tagId == 0) { var newTag = new Tag { Content = item }; tagRepository.CreateTag(newTag); tagRepository.Save(); var newTagId = tagRepository.GetNewTagId(newTag); tagRepository.AddToPost(postId, newTagId); tagRepository.Save(); } if (postTagRepository.IsExistPostTag(postId, tagId)) { continue; } else { tagRepository.AddToPost(postId, tagId); tagRepository.Save(); } } } else { var tagId = tagRepository.FindTagByContent(tags); if (tagId == 0) { var newTag = new Tag { Content = tags }; tagRepository.CreateTag(newTag); tagRepository.Save(); var newTagId = tagRepository.GetNewTagId(newTag); tagRepository.AddToPost(postId, newTagId); tagRepository.Save(); } else { if (postTagRepository.IsExistPostTag(postId, tagId)) { return; } else { tagRepository.AddToPost(postId, tagId); tagRepository.Save(); } } } }
public Tag CreateTag(string name) { return(_tagRepository.CreateTag(name, name.ToLower().ToEnumerable())); }
public Tag CreateTag(string stringTag) { var tag = _tagRepository.CreateTag(stringTag); return(tag); }