public async Task <UploadedContent> UploadContentsAsync([FromForm] NewContent content) { var contentsDir = _configuration["ContentsDirectory"]; var contentName = Guid.NewGuid().ToString("D") + "@" + content.Content.FileName; var fileDirPath = Path.Join(contentsDir, content.Owner, content.ScoreName); if (false == Directory.Exists(fileDirPath)) { Directory.CreateDirectory(fileDirPath); } try { await using var ws = System.IO.File.OpenWrite(Path.Join(fileDirPath, contentName)); await content.Content.CopyToAsync(ws); await ws.FlushAsync(); ws.Close(); } catch (Exception ex) { _logger.LogError(ex, ex.Message); } var contentsUrlBase = _configuration["ContentsUrlBase"].TrimEnd('/'); return(new UploadedContent() { Href = new Uri(contentsUrlBase + "/" + content.Owner + "/" + content.ScoreName + "/" + contentName), OriginalName = content.Content.FileName }); }
public void NewsPost(NewContent content) { using (var context = new DataDbContext()) { try { context.NewContent.Add(content); context.SaveChanges(); } catch (Exception) { throw; } } }
//used for adding new content to Confluence public static void AddContent(string title, string space, string body) { //gets space key using the space name string spaceKey = GetSpaceKey(space); //creates a NewContent object to be sent to confluence NewContent content = new NewContent { Title = title, Space = spaceKey, Body = body }; //makes the request to add the new page string teststring = RunQuery("content", null, null, ConvertNewContent(content), "POST"); }
public async Task <IActionResult> OnPostAsync(string slug) { WikiPage = await _wikiPageService.FindBySlug(slug); if (WikiPage == null) { return(NotFound()); } MostRecentRevision = await _revisionService.FindMostRecentByPageId(WikiPage.Id); await _revisionService.AddRevision(new WikiPageRevision() { PageId = WikiPage.Id, RevisionNumber = (MostRecentRevision?.RevisionNumber ?? 0) + 1, Created = DateTime.Now, Content = NewContent.Replace("\r\n", "\n"), Comment = NewComment }); return(RedirectToPage("ViewPage", new { slug })); }
public void SendNewContent(NewContent content) { using (var context = new DataDbContext()) { IQueryable <Subscribe> query = from sub in context.Subscribers select sub; foreach (var s in query) { try { using (var mail = new MailMessage()) { var stringBuilder = new StringBuilder(); mail.To.Add(s.EmailAddress); mail.From = new MailAddress("*****@*****.**"); mail.Subject = content.PostSubject; stringBuilder.Append("Hi " + s.FirstName + " " + s.LastName + "<br></br>"); stringBuilder.Append("<br></br>" + content.PostBody + "<br></br>"); stringBuilder.Append("<br></br>" + "Date Posted: " + content.PostEntryDate); mail.Body = stringBuilder.ToString(); mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential ("*****@*****.**", "Jedia.01"); smtp.EnableSsl = true; smtp.Send(mail); } } catch (System.Exception) { throw; } } } }
public ActionResult PostNews(NewContent content) { if (ModelState.IsValid == true) { content.PostEntryDate = System.DateTime.Now; var postNews = new PostLatest(); postNews.NewsPost(content); //Send notifications to Subscribers var notify = new Notifications(); notify.SendNewContent(content); ViewBag.SuccessPost = "Your entry has been sucessfully posted"; ModelState.Clear(); return(RedirectToAction("Dashboard", "Administrator")); } else { ViewBag.ErrorPost = "Could not post entry"; return(RedirectToAction("Dashboard", "Administrator")); } }
//converts new NewContent objects to JSON public static string ConvertNewContent(NewContent content) { JObject data = JObject.FromObject(new { title = content.Title, type = content.Type, space = new { key = content.Space }, body = new { storage = new { value = content.Body, representation = "storage" } } }); string returnstring = JsonConvert.SerializeObject(data); return(returnstring); }
public AzureDevOpsChange(string filePath, string content, string contentType = null) { Item = new Item(filePath); NewContent = new NewContent(content, contentType); ChangeType = AzureDevOpsChangeType.Edit; }
private void OnNewContent(EventArgs e) { NewContent?.Invoke(NewContent, e); }