public ActionResult NoticeDetails(int id)
        {
            Notice model = db.Notices.Find(id);

            if (model == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "No notice found with the specified ticket."));
            }
            var         replyexists = true;
            noticereply reply       = null;

            try
            {
                reply = db.noticereplies.Where(nr => nr.noticeid == id).First();
            }
            catch (Exception ex)
            {
                replyexists = false;
            }
            ViewBag.ReplyExists = replyexists;
            if (replyexists)
            {
                ViewBag.Reply = reply;
            }
            return(View(model));
        }
        public ActionResult NoticeDetails(int id)
        {
            var    loggedInUserId   = User.Identity.GetUserId();
            var    loggedInDriverId = db.Drivers.Where(d => d.UserId.Equals(loggedInUserId)).First().Id;
            Notice model            = null;

            try
            {
                model = db.Notices.Where(notice => notice.DriverId == loggedInDriverId).Where(notice => notice.Id == id).First();
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            var         replyexists = true;
            noticereply reply       = null;

            try
            {
                reply = db.noticereplies.Where(nr => nr.noticeid == id).First();
            }
            catch (Exception ex)
            {
                replyexists = false;
            }
            ViewBag.ReplyExists = replyexists;
            if (replyexists)
            {
                ViewBag.Reply = reply;
            }

            return(View(model));
        }
 public ActionResult ReplyToNotice(noticereply model)
 {
     if (ModelState.IsValid)
     {
         model.replydate = DateTime.Now;
         db.noticereplies.Add(model);
         db.SaveChanges();
         return(RedirectToAction("NoticeList"));
     }
     else
     {
         ModelState.AddModelError("", "Please fill in all the fields properly.");
         return(View(model));
     }
 }