//funkcja dodawania posta public bool DodajPosta(PostNew new_post) { try { Post post = new Post(); post.data_dodania = new_post.data_dodania; post.data_modyfikacji = new_post.data_modyfikacji; post.status = 0; post.tresc = new_post.tresc; post.tytul = new_post.tytul; db.Posts.InsertOnSubmit(post); db.SubmitChanges(); Tagi tag = new Tagi(); tag.id_post = post.id; tag.description = new_post.description; tag.keywords = new_post.keywords; db.Tagis.InsertOnSubmit(tag); db.SubmitChanges(); return true; } catch { return false; } }
//funkcja edytowania posta public bool EdytujPosta(int id, Post edit_post) { try { //Post oryginalPost = (from m in db.Posts where m.id == id select m).First(); Post oryginalPost = Edytuj(id); //oryginalPost.id=oryginalPost.id; //oryginalPost.data_dodania=oryginalPost.data_dodania; oryginalPost.data_modyfikacji = System.DateTime.Now; oryginalPost.tytul= edit_post.tytul; oryginalPost.tresc = edit_post.tresc; oryginalPost.status = edit_post.status; //db.Posts.InsertOnSubmit(oryginalPost); db.SubmitChanges(); return true; } catch { return false; } }
// // GET: /Administracja/DodajPost public ActionResult DodajPost() { var post = new Post(); ViewData["list"] = lista(); return View(post); }
public ActionResult Create() { // Post instanciation with date pre-filled var newPost = new Post(); newPost.Posted = DateTime.Now; return View(newPost); }
public ActionResult Create(Post post) { if (ModelState.IsValid) { db.Posts.Add(post); db.SaveChanges(); return RedirectToAction("Index"); } return View(post); }
public ActionResult Create(Post post) { if (ModelState.IsValid) { // Update date post.Posted = DateTime.Now; unitOfWork.PostRepository.InsertOrUpdate(post); unitOfWork.PostRepository.Save(); return RedirectToAction("Index"); } else { return View(); } }
public ActionResult EdytujPosta(int id, Post obiekt) { //<input type="text" value="<%=Model.id.ToString() %>" readonly = "readonly" /> if (db_admin.EdytujPosta(id, obiekt)) { ViewData["action"] = "Post zostal zedytowany ;)"; } else { ViewData["action"] = "Post nie zostal zedytowany ;("; } return View(obiekt); }
public ActionResult Edycja(int id,Post post) { var Ppost = blogDB.Post.Single(a => a.id == id); try { Ppost = post; blogDB.SaveChanges(); return RedirectToAction("Index"); } catch { return View(Ppost); } }
public ActionResult Create(Post post) { if (ModelState.IsValid) { post.EntryDateTime = DateTime.Now; db.Posts.Add(post); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", post.CategoryId); ViewBag.AuthorId = new SelectList(db.Authors, "AuthorId", "Name", post.AuthorId); return View("Create", post); }
private WilderMinds.MetaWeblog.Post ToMetaWebLogPost(Models.Post post) { var request = _context.HttpContext.Request; string url = request.Scheme + "://" + request.Host; return(new WilderMinds.MetaWeblog.Post { postid = post.ID, title = post.Title, wp_slug = post.Slug, permalink = url + post.GetLink(), dateCreated = post.PubDate, description = post.Content, categories = post.Categories.ToArray() }); }
// POST api/Post public HttpResponseMessage PostPost(Post post) { if (ModelState.IsValid) { db.Posts.Add(post); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, post); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = post.PostId })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
public string AddPost(string blogid, string username, string password, WilderMinds.MetaWeblog.Post post, bool publish) { ValidateUser(username, password); var newPost = new Models.Post { Title = post.title, Slug = !string.IsNullOrWhiteSpace(post.wp_slug) ? post.wp_slug : Models.Post.CreateSlug(post.title), Content = post.description, IsPublished = publish, Categories = post.categories }; if (post.dateCreated != DateTime.MinValue) { newPost.PubDate = post.dateCreated; } _blog.SavePost(newPost).GetAwaiter().GetResult(); return(newPost.ID); }
public ActionResult DodajPost(Post collection) { if (ModelState.IsValid) { DateTime now=DateTime.Now; now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second); collection.data_dodania = now; blogDB.AddToPost(collection); blogDB.SaveChanges(); int post_id = blogDB.Post.Single(p => p.data_dodania == collection.data_dodania).id; Tagi tag = new Tagi(); tag.id_posta = post_id; return View("Tagi",tag); } else { ViewData["list"] = lista(); return View(collection); } }
// PUT api/Post/5 public HttpResponseMessage PutPost(int id, Post post) { if (ModelState.IsValid && id == post.PostId) { db.Entry(post).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
//public async Task<ActionResult> Create([Bind(Include = "Id,PostCreationDate,PostTitle,PostContent,MediaUrl,Published,AuthorId,PostUpdateDate,PostUpdateReason,EditorId")] Post post) //public async Task<ActionResult> Create([Bind(Include = "Id,PostCreationDate,PostTitle,PostContent,Published,AuthorId")] Post post) //public async Task<ActionResult> Create([Bind(Include = "Id,PostCreationDate,PostTitle,PostContent,MediaUrl,Published,AuthorId")] Post post, HttpPostedFileBase MediaUrl) public async Task<ActionResult> Create (Post post, HttpPostedFileBase File) { if (ModelState.IsValid) { post.PostCreationDate = new DateTimeOffset(DateTime.Now); post.AuthorId = db.Users.FirstOrDefault(u => u.UserName == User.Identity.Name).Id; //restricting the valid file formats to images only if (ImageUploadValidator.IsWebFriendlyImage(fileUpload)) { var fileName = Path.GetFileName(fileUpload.FileName); fileUpload.SaveAs(Path.Combine(Server.MapPath("~/Images"), fileName)); post.MediaUrl = "~/Images" + fileName; } db.Posts.Add(post); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(post); }
partial void DeletePost(Post instance);
public ActionResult Edit(Post post) { //Retrieve CKeditor value //post.IntroText = HttpUtility.HtmlDecode(post.IntroText); //post.BodyText = HttpUtility.HtmlDecode(post.BodyText); if (ModelState.IsValid) { post.EntryDateTime = DateTime.Now; db.Entry(post).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", post.CategoryId); ViewBag.AuthorId = new SelectList(db.Authors, "AuthorId", "Name", post.AuthorId); return View(post); }
partial void InsertPost(Post instance);
partial void UpdatePost(Post instance);
public ActionResult Edit(Post post) { if (ModelState.IsValid) { unitOfWork.PostRepository.InsertOrUpdate(post); unitOfWork.PostRepository.Save(); return RedirectToAction("Index"); } else { return View(); } }
/// <summary> /// Create a new Post object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="data_dodania">Initial value of the data_dodania property.</param> /// <param name="tytul">Initial value of the tytul property.</param> /// <param name="tresc">Initial value of the tresc property.</param> /// <param name="status">Initial value of the status property.</param> public static Post CreatePost(global::System.Int32 id, global::System.DateTime data_dodania, global::System.String tytul, global::System.String tresc, global::System.Int32 status) { Post post = new Post(); post.id = id; post.data_dodania = data_dodania; post.tytul = tytul; post.tresc = tresc; post.status = status; return post; }
/// <summary> /// Deprecated Method for adding a new object to the Post EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPost(Post post) { base.AddObject("Post", post); }
public void InsertOrUpdate(Post post) { if (post.Id == default(System.Guid)) { // New entity post.Id = Guid.NewGuid(); context.Posts.Add(post); } else { // Existing entity context.Entry(post).State = EntityState.Modified; } }
public ActionResult UsunPosta(int id, Post post) { //<input type="text" value="<%=Model.id.ToString() %>" readonly = "readonly" /> if (db_admin.UsunPosta(id)) { ViewData["action"] = "Post zostal usuniety ;)"; } else { ViewData["action"] = "Post nie zostal usuniety ;("; } return View(post); }
public ActionResult UsunPost(Post collection) { try { var post = blogDB.Post.Include("Komentarze").Include("Tagi").Single(p => p.id == collection.id); blogDB.DeleteObject(post); blogDB.SaveChanges(); return RedirectToAction("Index"); } catch { return View("Error"); } }
public ActionResult EdytujPost(Post collection) { Post post = blogDB.Post.Single(p => p.id == collection.id); if (ModelState.IsValid) { collection.data_modyfikacji = DateTime.Now; post = collection; blogDB.Post.ApplyCurrentValues(post); blogDB.SaveChanges(); return RedirectToAction("Index"); } ViewData["list"] = lista(); return View(collection); }
public ActionResult Edit(Post post) { if (ModelState.IsValid) { db.Entry(post).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(post); }
private SyndicationItem GetSyndicationItem(Post post) { return new SyndicationItem(post.Title, post.Body, new Uri("http://www.tanianatiunina.com/posts/detail/" + post.Id)); }