public ActionResult Edit(Magazine magazine, string receiver) { if (ModelState.IsValid) { //New Files for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); FileDetail fileDetail = new FileDetail() { FileName = fileName, Extension = Path.GetExtension(fileName), Id = Guid.NewGuid(), MagazineID = magazine.MagazineID }; var path = Path.Combine(Server.MapPath("~/App_Data/Upload/"), fileDetail.Id + fileDetail.Extension); file.SaveAs(path); db.Entry(fileDetail).State = EntityState.Added; } } ViewBag.TopicID = new SelectList(db.Topics, "TopicID", "TopicName", magazine.TopicID); db.Entry(magazine).State = EntityState.Modified; db.SaveChanges(); string subject = "Your student has Delete their post submission for your Topic"; string body = "Hi Marketing Coordinator," + "Your student has editted their post submission for your Topic: " + magazine.TopicName + " Student's name: " + User.Identity.Name + " Submit Date: " + DateTime.Now; WebMail.Send(receiver, subject, body); return(RedirectToAction("Index")); } return(View(magazine)); }
public async Task <IActionResult> PutMagazine(int id, Magazine magazine) { if (id != magazine.Id) { return(BadRequest()); } _context.Entry(magazine).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MagazineExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "TopicID,TopicName,TopicClousureDate,TopicFinalClousureDate,TopicPostDate")] Topic topic) { if (ModelState.IsValid) { db.Entry(topic).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(topic)); }
public ActionResult Edit([Bind(Include = "CommentId,Comment,CommentOn,CommentBy,MagazineID")] ArticlesComment articlesComment) { if (ModelState.IsValid) { db.Entry(articlesComment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MagazineID = new SelectList(db.Magazines, "MagazineID", "MagazineName", articlesComment.MagazineID); return(View(articlesComment)); }
public void Update(TEntity item) { _context.Entry(item).State = EntityState.Modified; }