public ActionResult DeleteConfirmed(Guid id) { TimeOffEvent timeOffEvent = db.TimeOffEvents.Find(id); db.TimeOffEvents.Remove(timeOffEvent); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "EventId,StartTime,EndTime,Message,Title,AdminId")] TimeOffEvent timeOffEvent) { if (ModelState.IsValid) { db.Entry(timeOffEvent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(timeOffEvent)); }
public ActionResult Edit([Bind(Include = "Id,EventID,Start,End,Note,Title,ActiveSchedule,ApproverId,Submitted")] TimeOffEvent timeOffEvent) { if (ModelState.IsValid) { db.Entry(timeOffEvent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(timeOffEvent)); }
public ActionResult Edit([Bind(Include = "EventID,Start,End,ActiveSchedule,Submitted,Id")] TimeOffEvent timeOffEvent) { if (ModelState.IsValid) { db.Entry(timeOffEvent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Users, "Id", "FirstName", timeOffEvent.Id); return(View(timeOffEvent)); }
public ActionResult Create([Bind(Include = "Id,EventID,Start,End,Note,Title,ActiveSchedule,ApproverId,Submitted")] TimeOffEvent timeOffEvent) { if (ModelState.IsValid) { timeOffEvent.Submitted = DateTime.Now; db.TimeOffEvents.Add(timeOffEvent); timeOffEvent.Id = HttpContext.User.Identity.GetUserId(); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(timeOffEvent)); }
// GET: TimeOffEvent/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TimeOffEvent timeOffEvent = db.TimeOffEvents.Find(id); if (timeOffEvent == null) { return(HttpNotFound()); } return(View(timeOffEvent)); }
// GET: TimeOffEvent/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TimeOffEvent timeOffEvent = (TimeOffEvent)db.TimeOffEvents.Find(id); if (timeOffEvent == null) { return(HttpNotFound()); } return(View(timeOffEvent)); }
public ActionResult Create([Bind(Include = "EventId,StartTime,EndTime,Message,Title,AdminId")] TimeOffEvent timeOffEvent) { if (ModelState.IsValid) { timeOffEvent.EventId = Guid.NewGuid(); timeOffEvent.Submitted = DateTime.Now; db.TimeOffEvents.Add(timeOffEvent); db.SaveChanges(); //Once the form has been submitted, return to home return(View("~/Views/Home/Index.cshtml")); } return(View(timeOffEvent)); }
public ActionResult Create([Bind(Include = "EventID,Start,End,ActiveSchedule,Submitted,Id")] TimeOffEvent timeOffEvent) { if (ModelState.IsValid) { timeOffEvent.EventID = Guid.NewGuid(); db.TimeOffEvents.Add(timeOffEvent); timeOffEvent.Submitted = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Users, "Id", "FirstName", timeOffEvent.Id); return(PartialView(timeOffEvent)); }
// GET: TimeOffEvent/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TimeOffEvent timeOffEvent = db.TimeOffEvents.Find(id); if (timeOffEvent == null) { return(HttpNotFound()); } ViewBag.Id = new SelectList(db.Users, "Id", "FirstName", timeOffEvent.Id); return(View(timeOffEvent)); }
public ActionResult Create([Bind(Include = "Id,EventID,Start,End,Note,Title,ActiveSchedule,ApproverId,Submitted")] TimeOffEvent timeOffEvent) { if (ModelState.IsValid) { // Setting the submitted time to now timeOffEvent.Submitted = DateTime.Now; // Setting the eventID to a new unique GUID, without this, it is all 0s timeOffEvent.EventID = Guid.NewGuid(); db.TimeOffEvents.Add(timeOffEvent); timeOffEvent.Id = HttpContext.User.Identity.GetUserId(); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(timeOffEvent)); }
public ActionResult Create([Bind(Include = "EventID,Start,End,Note,ActiveSchedule,Submitted,Id")] TimeOffEvent timeOffEvent) { if (ModelState.IsValid) { var userid = User.Identity.GetUserId(); timeOffEvent.User = db.Users.Where(w => w.Id == userid).First(); timeOffEvent.EventID = Guid.NewGuid(); timeOffEvent.Submitted = DateTime.Now; db.TimeOffEvents.Add(timeOffEvent); db.SaveChanges(); return(new EmptyResult()); } ViewBag.Id = new SelectList(db.Users, "Id", "FirstName", timeOffEvent.Id); return(View(timeOffEvent)); }
public virtual TimeOffEvent TimeOffEventID { get; set; } //Column header: TimeOffEventID_TimeOffEventID public Message(TimeOffEvent e, string s, ApplicationDbContext db) : this() { Recipient = db.Users.Find(e.User.Id); TimeOffEventID = e; Sender = db.Users.Find(s); DateSent = DateTime.Now; string state = ""; if (e.ActiveSchedule == true) { state = "approved"; } else if (e.ActiveSchedule == false) { state = "denied"; } MessageTitle = "Your time off request has been " + state + "."; Content = Sender.FirstName + " has " + state + " your time off request from " + e.Start + " to " + e.End + ". " + e.Note; }