public ActionResult DeleteByPromoter(Guid id) { DailyPromoterPlanAttachment dailyPromoterPlanAttachment = db.DailyPromoterPlanAttachments.Find(id); dailyPromoterPlanAttachment.IsDeleted=true; dailyPromoterPlanAttachment.DeletionDate=DateTime.Now; db.SaveChanges(); return RedirectToAction("PromoterDailyPlanAction","DailyPromoterPlans"); }
public ActionResult DeleteConfirmed(Guid id) { DailyPromoterPlanAttachment dailyPromoterPlanAttachment = db.DailyPromoterPlanAttachments.Find(id); dailyPromoterPlanAttachment.IsDeleted=true; dailyPromoterPlanAttachment.DeletionDate=DateTime.Now; db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Edit([Bind(Include = "Id,FileUrl,DailyPromoterPlanId,IsActive,CreationDate,LastModifiedDate,IsDeleted,DeletionDate,Description")] DailyPromoterPlanAttachment dailyPromoterPlanAttachment) { if (ModelState.IsValid) { dailyPromoterPlanAttachment.IsDeleted=false; db.Entry(dailyPromoterPlanAttachment).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.DailyPromoterPlanId = new SelectList(db.DailyPromoterPlans, "Id", "Description", dailyPromoterPlanAttachment.DailyPromoterPlanId); return View(dailyPromoterPlanAttachment); }
// GET: DailyPromoterPlanAttachments/Details/5 public ActionResult Details(Guid? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } DailyPromoterPlanAttachment dailyPromoterPlanAttachment = db.DailyPromoterPlanAttachments.Find(id); if (dailyPromoterPlanAttachment == null) { return HttpNotFound(); } return View(dailyPromoterPlanAttachment); }
// GET: DailyPromoterPlanAttachments/Edit/5 public ActionResult Edit(Guid? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } DailyPromoterPlanAttachment dailyPromoterPlanAttachment = db.DailyPromoterPlanAttachments.Find(id); if (dailyPromoterPlanAttachment == null) { return HttpNotFound(); } ViewBag.DailyPromoterPlanId = new SelectList(db.DailyPromoterPlans, "Id", "Description", dailyPromoterPlanAttachment.DailyPromoterPlanId); return View(dailyPromoterPlanAttachment); }
public ActionResult PromoterDailyPlanAction(List <HttpPostedFileBase> attachments) { #region Upload and resize image if needed if (attachments != null) { foreach (HttpPostedFileBase t in attachments) { if (t != null) { User user = GetUserInfo.GetUser(); DailyPromoterPlan dailyPromoterPlan = db.DailyPromoterPlans.FirstOrDefault(c => c.ProjectDetailPromoter.UserId == user.Id && c.ShiftDate == DateTime.Today); if (dailyPromoterPlan != null) { string filename = Path.GetFileName(t.FileName); string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty) + Path.GetExtension(filename); string newFilenameUrl = "/Uploads/PromoterAttachment/" + newFilename; string physicalFilename = Server.MapPath(newFilenameUrl); t.SaveAs(physicalFilename); DailyPromoterPlanAttachment dailyPromoterPlanAttachment = new DailyPromoterPlanAttachment() { Id = Guid.NewGuid(), FileUrl = newFilenameUrl, CreationDate = DateTime.Now, DailyPromoterPlanId = dailyPromoterPlan.Id, IsActive = true, IsDeleted = false, }; db.DailyPromoterPlanAttachments.Add(dailyPromoterPlanAttachment); } } } db.SaveChanges(); } #endregion return(RedirectToAction("PromoterDailyPlanAction")); }
public ActionResult Create([Bind(Include = "Id,FileUrl,DailyPromoterPlanId,IsActive,CreationDate,LastModifiedDate,IsDeleted,DeletionDate,Description")] DailyPromoterPlanAttachment dailyPromoterPlanAttachment) { if (ModelState.IsValid) { dailyPromoterPlanAttachment.IsDeleted=false; dailyPromoterPlanAttachment.CreationDate= DateTime.Now; dailyPromoterPlanAttachment.Id = Guid.NewGuid(); db.DailyPromoterPlanAttachments.Add(dailyPromoterPlanAttachment); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.DailyPromoterPlanId = new SelectList(db.DailyPromoterPlans, "Id", "Description", dailyPromoterPlanAttachment.DailyPromoterPlanId); return View(dailyPromoterPlanAttachment); }