public async Task <ActionResult> Create(AnnouncementPost model) { var a = PostAnnouncementt(model); string yourStringValue = a.AnnouncementId + a.Email; //var hashValue = string.Join("", MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(yourStringValue)).Select(s => s.ToString("x2"))); string hashed = GenerateMD5(yourStringValue); try { string body = "<a href='http://*****:*****@gmail.com", //email.Sender, Recipient = model.Email, RecipientCC = null, Subject = model.Title + " for sale", Body = body }; MailHelper.Send(); } catch (Exception e) { ModelState.AddModelError("err", e); return(View()); } return(RedirectToAction("List")); }
private void MergeVersionData(AnnouncementPost announcementPost, AnnouncementPost versionData) { announcementPost.VersionCode = versionData.VersionCode; announcementPost.Status = versionData.Status; announcementPost.Title = versionData.Title; announcementPost.Excerp = versionData.Excerp; announcementPost.Image = versionData.Image; announcementPost.Caption = versionData.Caption; announcementPost.Posted = versionData.Posted; announcementPost.Content = versionData.Content; announcementPost.ContentTreeId = versionData.ContentTreeId; announcementPost.UserId = versionData.UserId; }
// POST: Announcement public HttpResponseMessage PostAnnouncement(AnnouncementPost a) { RestClient <AnnouncementPost> rc = new RestClient <AnnouncementPost>(); rc.WebServiceUrl = "http://localhost:10469/api/Announcements/NewAnnouncement"; //rc.WebServiceUrl = "http://api.summercamp.stage02.netromsoftware.ro/api/announcements/newannouncement"; HttpResponseMessage response = rc.PostAsync(a); var id = response.Content.ReadAsStringAsync().Result; //string id = Request.Params["id"]; //string type = Request.QueryString["id"]; return(response); }
/// <summary> /// Creates a new AnnouncementPost with scaffolded content /// </summary> public AnnouncementPost CreateAnnouncementPost(string userId) { var announcementPost = new AnnouncementPost() { Id = KeyGen.NewGuid() }; // Default Settings announcementPost.Title = "New Announcement Post"; announcementPost.Excerp = "Enter a brief description about your announcement..."; announcementPost.Image = "/img/seedimages/announcement-1.jpg"; announcementPost.Posted = DateTime.Now; announcementPost.UserId = userId; announcementPost.Published = false; // Create a new content version and add the announcement post model var versionInfo = _contentManager.CreateDraftVersion(CONTENT_TYPE_ANNOUNCEMENTPOST, announcementPost.Id, userId).Result; // Create a new contrent tree for this version and use tree builder to insert some content var contentTree = _contentManager.CreateContentTree(versionInfo).Result; var treeBuilder = _contentManager.CreateTreeBuilder(contentTree); treeBuilder.AddRootContent("post-body", settings => { settings.WidgetType = "html"; settings.ModelName = "lorem-ipsum"; // from Angelo.Connect.Web.Data.Json, html.json }); treeBuilder.AddRootContent("post-body", settings => { settings.WidgetType = "image"; settings.ModelName = "idea-banner"; // from Angelo.Connect.Web.Data.Json, image.json }); // save the tree treeBuilder.SaveChanges(); // save the model announcementPost.VersionCode = versionInfo.VersionCode; announcementPost.Status = ContentStatus.Scratch; // versionInfo.Status; announcementPost.ContentTreeId = contentTree.Id; _announcementDbContext.AnnouncementPosts.Add(announcementPost); _announcementDbContext.SaveChanges(); var versionData = ExtractVersionData(announcementPost); _contentManager.SetVersionModelData(versionInfo, versionData).Wait(); return(announcementPost); }
public void DeleteAnnouncementPost(AnnouncementPost announcementPost) { // remove content records _contentManager.DeleteAllVersions(CONTENT_TYPE_ANNOUNCEMENTPOST, announcementPost.Id).Wait(); _contentManager.DeleteAllContentTrees(CONTENT_TYPE_ANNOUNCEMENTPOST, announcementPost.Id).Wait(); // remove child associations ClearAnnouncementPostCategories(announcementPost.Id); ClearAnnouncementPostTags(announcementPost.Id); // remove the post _announcementDbContext.AnnouncementPosts.Remove(announcementPost); _announcementDbContext.SaveChanges(); }
public AnnouncementReturn PostAnnouncementt(AnnouncementPost a) { RestClient <AnnouncementPost> rc = new RestClient <AnnouncementPost>(); rc.WebServiceUrl = "http://localhost:10469/api/Announcements/NewAnnouncement"; //rc.WebServiceUrl = "http://api.summercamp.stage02.netromsoftware.ro/api/announcements/newannouncement"; HttpResponseMessage response = rc.PostAsync(a); var id = response.Content.ReadAsStringAsync().Result; //var c = JsonConvert.DeserializeObject<List<AnnouncementPost>>(id); AnnouncementReturn taskModels = JsonConvert.DeserializeObject <AnnouncementReturn>(id); //string c = JsonConvert.DeserializeObject<string>(id); return(taskModels); }
private IEnumerable <SecurityClaimConfig> BuildPostPrivacyOptions(AnnouncementPost post) { return(new List <SecurityClaimConfig>() { new SecurityClaimConfig { Title = "Post Privacy", Description = "Manage who can view post.", AllowRoles = false, AllowUsers = false, AllowGroups = true, Claim = new Claim(AnnouncementClaimTypes.AnnouncementPostRead, post.Id), ResourceType = typeof(Angelo.Connect.Announcement.Models.AnnouncementPost).ToString() } }); }
private AnnouncementPost ExtractVersionData(AnnouncementPost announcementPost) { return(new AnnouncementPost { Id = announcementPost.Id, VersionCode = announcementPost.VersionCode, Status = announcementPost.Status, Title = announcementPost.Title, Excerp = announcementPost.Excerp, Image = announcementPost.Image, Caption = announcementPost.Caption, Posted = announcementPost.Posted, Content = announcementPost.Content, ContentTreeId = announcementPost.ContentTreeId, UserId = announcementPost.UserId }); }
private string SerializeVersionData(AnnouncementPost announcementPost) { var data = new AnnouncementPost { Id = announcementPost.Id, VersionCode = announcementPost.VersionCode, Status = announcementPost.Status, Title = announcementPost.Title, Excerp = announcementPost.Excerp, Image = announcementPost.Image, Caption = announcementPost.Caption, Posted = announcementPost.Posted, Content = announcementPost.Content, ContentTreeId = announcementPost.ContentTreeId, UserId = announcementPost.UserId }; return(JsonConvert.SerializeObject(data, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Include })); }
public AnnouncementPost CloneAnnouncementPostAsDraft(AnnouncementPost announcementPost, string userId) { var oldVersionInfo = _contentManager.GetVersionInfo(CONTENT_TYPE_ANNOUNCEMENTPOST, announcementPost.Id, announcementPost.VersionCode).Result; if (oldVersionInfo == null) { throw new Exception($"Cannot clone AnnouncementPost. AnnouncementPost {announcementPost.Id}, version {announcementPost.VersionCode} does not exist."); } var versionInfo = _contentManager.CreateDraftVersion(CONTENT_TYPE_ANNOUNCEMENTPOST, announcementPost.Id, userId).Result; var clonedContentTree = _contentManager.CloneContentTree(announcementPost.ContentTreeId, versionInfo.VersionCode).Result; var clonedAnnouncementPost = announcementPost.Clone(); clonedAnnouncementPost.Status = versionInfo.Status; clonedAnnouncementPost.VersionCode = versionInfo.VersionCode; clonedAnnouncementPost.ContentTreeId = clonedContentTree.Id; var versionData = ExtractVersionData(clonedAnnouncementPost); _contentManager.SetVersionModelData(versionInfo, versionData).Wait(); return(clonedAnnouncementPost); }
public void UpdateAnnouncementPost(AnnouncementPost announcementPost) { var versionInfo = _contentManager.GetVersionInfo(CONTENT_TYPE_ANNOUNCEMENTPOST, announcementPost.Id, announcementPost.VersionCode).Result; if (versionInfo == null) { throw new Exception($"Cannot update AnnouncementPost. AnnouncementPost {announcementPost.Id} does not have a draft version to edit."); } if (versionInfo.Status == ContentStatus.Published) { throw new Exception("Cannot update a published AnnouncementPost"); } var announcementPostCurrent = GetAnnouncementPost(announcementPost.Id); var versionData = _contentManager.GetStoredData <AnnouncementPost>(versionInfo); versionData.Title = announcementPost.Title; versionData.Excerp = announcementPost.Excerp; versionData.Image = announcementPost.Image; versionData.Caption = announcementPost.Caption; versionData.Content = announcementPost.Content; versionData.Posted = DateTime.Now; versionData.Status = ContentStatus.Draft; if (announcementPostCurrent.VersionCode == versionData.VersionCode) { // also update the announcement's phyical copy if version is the same MergeVersionData(announcementPostCurrent, versionData); _announcementDbContext.SaveChanges(); } // persist the content model in the version data _contentManager.SetVersionModelData(versionInfo, versionData).Wait(); }
public ActionResult Edit(AnnouncementPost a) { //PutAnnouncement(a.Id ,a); return(RedirectToAction("List")); }
public ActionResult Edit(int id) { AnnouncementPost a = GetAnnouncementByIdw(id); return(View(a)); }