}//TagConfirm (sends back list of tags to be added for confirmation) public JsonResult AddTags(string TagInput) { string[] split = TagInput.ToString().Split(new char[] { ' ', ',', '.' }); List <Tags> list = new List <Tags>(); foreach (var i in split) { if (i.Trim() != "") { i.TrimStart(); i.TrimEnd(); var first = i.Substring(0, 1); var rest = i.Substring(1); var str = first.ToUpper() + rest; if (!_context.Tags.Any(t => t.Tag == str) && !list.Any(t => t.Tag == str)) { list.Add(new Tags { Tag = str }); } } } _context.AddRange(list); _context.SaveChanges(); return(Json("Added " + list)); }//AddTags (Create)
}//AssignFileTags (View) public JsonResult RemoveTagFromFile(int FileTagID) { var FileTag = _context.AudioFilesTags.Find(FileTagID); try { _context.AudioFilesTags.Remove(FileTag); _context.SaveChanges(); return(Json("Removed")); } catch { return(Json("Failed")); } }//RemoveTagFromFile (Delete)
}//DuplicateCheck (Check against user input) public JsonResult AddFiles(string FileName, string Desc) { AudioFiles AudioFile = new AudioFiles() { File = FileName, Description = Desc }; bool Exists = AlreadyExists(null, AudioFile.File); if(!Exists) { _context.Add(AudioFile); _context.SaveChanges(); return Json("Added"); } else if(Exists) { return Json("Duplicate"); } return Json("Failed"); }//AddFiles (Create)