public WorkIssue ProcessEmbedQuestions(WorkIssue issue) { var _commands = issue.GetCommands(); if (_commands != null && _commands.Count() > 0) { foreach (string _command in _commands) { if (_command.CountOf(",") >= 2) { string _id = _command.Split(new string[] { "," }, StringSplitOptions.None)[1] .Replace("#", string.Empty); try { Guid id = Guid.Parse(_id); var _question = QuestionManager.GetById(id); string _htmlQuestion = RenderViewToString(ControllerContext, "Questions/_EmbedQuestion", _question); issue.Content = issue.Content.Replace(_command, _htmlQuestion); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } return(issue); }
//public bool AddContact(Guid id, Contact contact) //{ // bool _result = false; // var issue = IssueManager.GetById(id); // if (issue == null) { return _result; } // var _contacts = IssueManager.GetContacts(id); //} public WorkIssue ProcessEmbedUrls(WorkIssue issue) { var _commands = issue.GetCommands(); if (_commands != null && _commands.Count() > 0) { foreach (string command in _commands) { var _command = new Command(command); if (_command.Type == Models.CommandType.IsUrl) { try { string _id = command.Split(new string[] { "," }, StringSplitOptions.None)[1] .Replace("#", string.Empty); Guid id = Guid.Parse(_id); var _url = UrlManager.GetById(id); _url.Load(); if (_url.Title.IsNullOrEmptyOrWhiteSpace()) { UrlManager.Update(_url); } string _htmlQuestion = RenderViewToString(ControllerContext, "Urls/_EmbedUrl", _url); issue.Content = issue.Content.Replace(command, _htmlQuestion); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } } return(issue); }
public bool Insert(WorkIssue issue) { string[] _commands = issue.GetCommands(); if (_commands != null && _commands.Count() > 0) { foreach (string _command in _commands) { Command command = new Command(_command); if (command.Type == Models.CommandType.IsQuestion) { Question question = new Question(); question.Id = Guid.NewGuid(); question.IssueId = issue.Id; question.Title = HttpUtility.HtmlDecode(command.Title); question.Content = command.Body; question.CreatedBy = issue.CreatedBy; _unitOfWorkAsync.RepositoryAsync <Question>().Insert(question); issue.Content = issue.Content .Replace(_command, _command.AddAfter(',', ",#" + question.Id.ToString())); } else if (command.Type == Models.CommandType.IsUrl) { var urlModel = new Url(command.Header); urlModel.Load(); urlModel.CreatedBy = issue.CreatedBy; urlModel.IssueId = issue.Id; _unitOfWorkAsync.RepositoryAsync <Url>().Insert(urlModel); issue.Content = issue.Content .Replace(_command, command.Text.AddAfter(',', ",#" + urlModel.Id.ToString())); } } } _unitOfWorkAsync.RepositoryAsync <WorkIssue>().Insert(issue); int _result = _unitOfWorkAsync.SaveChangesAsync().Result; if (_result >= 0) { Notify(issue); return(true); } else { return(false); } }
private void ProcessIssueCommands(WorkIssue issue) { string[] _commands = issue.GetCommands(); if (_commands != null && _commands.Count() > 0) { foreach (string _command in _commands) { if (!_command.Contains("#")) { Command command = new Command(_command); if (command.Type == Models.CommandType.IsQuestion) { Question question = new Question(); question.Id = Guid.NewGuid(); question.IssueId = issue.Id; question.Title = HttpUtility.HtmlDecode(command.Title); question.Content = command.Body; question.CreatedBy = issue.CreatedBy; _unitOfWorkAsync.RepositoryAsync <Question>().Insert(question); issue.Content = issue.Content .Replace(_command, _command.AddAfter(',', ",#" + question.Id.ToString())); } if (command.Type == Models.CommandType.IsUrl) { Url url = new Url(); url.Id = Guid.NewGuid(); url.IssueId = issue.Id; url.Title = HttpUtility.HtmlDecode(command.Title); url.CreatedBy = issue.CreatedBy; _unitOfWorkAsync.RepositoryAsync <Url>().Insert(url); issue.Content = issue.Content .Replace(_command, _command.AddAfter(',', ",#" + url.Id.ToString())); } } } } }