public async Task <ActionResult> Create([Bind(Include = "RSSFeedsId,Title,Description,PublishedDate,Image,FeedType,Feedurl,Id")] RSSFeeds rSSFeeds, HttpPostedFileBase file) { if (ModelState.IsValid) { //uploading image file if (file != null) { byte[] imageBytes = null; BinaryReader reader = new BinaryReader(file.InputStream); imageBytes = reader.ReadBytes((int)file.ContentLength); rSSFeeds.Image = imageBytes; } rSSFeeds.RSSFeedsId = Guid.NewGuid(); //assign ID as the user ID rSSFeeds.Id = User.Identity.GetUserId(); rSSFeeds.PublishedDate = DateTime.Now; db.RSSFeeds.Add(rSSFeeds); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } // ViewBag.Id = new SelectList(db.ApplicationUsers, "Id", "FirstName", rSSFeeds.Id); return(View(rSSFeeds)); }
public async Task <ActionResult> DeleteConfirmed(Guid id) { RSSFeeds rSSFeeds = await db.RSSFeeds.FindAsync(id); db.RSSFeeds.Remove(rSSFeeds); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// GET: RSSFeeds/Details/5 public async Task <ActionResult> Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RSSFeeds rSSFeeds = await db.RSSFeeds.FindAsync(id); if (rSSFeeds == null) { return(HttpNotFound()); } return(View(rSSFeeds)); }
public async Task <ActionResult> Edit([Bind(Include = "RSSFeedsId,Title,Description,PublishedDate,Image,FeedType,Feedurl,Id")] RSSFeeds rSSFeeds) { if (ModelState.IsValid) { db.Entry(rSSFeeds).State = EntityState.Modified; rSSFeeds.Id = User.Identity.GetUserId(); rSSFeeds.PublishedDate = DateTime.Now; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } // ViewBag.Id = new SelectList(db.ApplicationUsers, "Id", "FirstName", rSSFeeds.Id); return(View(rSSFeeds)); }
// GET: RSSFeeds/Edit/5 public async Task <ActionResult> Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RSSFeeds rSSFeeds = await db.RSSFeeds.FindAsync(id); if (rSSFeeds == null) { return(HttpNotFound()); } // ViewBag.Id = new SelectList(db.ApplicationUsers, "Id", "FirstName", rSSFeeds.Id); return(View(rSSFeeds)); }