public void CanConvertStringToTags(string input, string tagName, int count, bool expected) { TagManager mgr = new TagManager(); GenericResponse <List <Tag> > response = mgr.ConvertTagStringToList(input); bool actual = response.Success; if (actual) { foreach (var t in response.Payload) { actual = t.TagName == tagName; if (!actual) { break; } } } if (actual) { actual = count == response.Payload.Count; } Assert.AreEqual(expected, actual); }
//[Authorize(Roles = "Marketing")] public ActionResult EditSubmission(SubmissionVM model) { if (ModelState.IsValid) { var postMgr = new PostManager(); var catMgr = new CategoryManager(); var tagMgr = new TagManager(); var editTarget = postMgr.GetById(int.Parse(model.SubmissionId)); //sub.Id = int.Parse(model.SubmissionId); editTarget.Payload.PostTitle = model.SubmissionTitle; editTarget.Payload.PostBody = model.SubmissionBody; editTarget.Payload.PostImageFileName = model.SubmissionImageFileName; var catResponse = catMgr.GetCategoryById(int.Parse(model.SubmissionCategoryId)); if (catResponse.Success) { editTarget.Payload.PostCategory = catResponse.Payload; } else { throw new Exception(catResponse.Message); } var tagResponse = tagMgr.ConvertTagStringToList(model.SubmissionTags); if (tagResponse.Success) { var tagList = new List <Tag>(); foreach (var t in tagResponse.Payload) { t.Posts.Add(editTarget.Payload); tagMgr.AddTag(t); tagList.Add(t); } editTarget.Payload.PostTags = tagList; } else { throw new Exception(); } editTarget.Payload.PostState = PostState.Pending; editTarget.Payload.Username = User.Identity.Name; var subResponse = postMgr.EditPost(editTarget.Payload); if (subResponse.Success) { return(RedirectToAction("ViewSubmissions")); } else { throw new Exception(subResponse.Message); } } else { return(View(model)); } }