public ActionResult Create(Tasks tasks)
        {
            if (ModelState.IsValid)
            {
                tasks.TaskId = Guid.NewGuid();

                db.Tasks.Add(tasks);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.AssignedTo = new SelectList(db.UserProfile, "UserId", "UserName", tasks.AssignedTo);
            ViewBag.RequestedBy = new SelectList(db.UserProfile, "UserId", "UserName", tasks.RequestedBy);
            ViewBag.LastModifiedDate = DateTime.Now;
            return View(tasks);
        }
 public void MarkAsModified(Tasks item)
 {
 }
        public ActionResult Edit(Tasks tasks)
        {
            if (tasks.AssignedUser == null)
                tasks.AssignedUser = db.UserProfile.First(u => u.UserId == tasks.AssignedTo);
            if (tasks.RequestedUser == null)
                tasks.RequestedUser = db.UserProfile.First(u => u.UserId == tasks.RequestedBy);

            tasks.LastModifiedDate = DateTime.Now;
            var errors = ModelState.Values.SelectMany(v => v.Errors);
            if (ModelState.IsValid)
            {
                db.MarkAsModified(tasks);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.AssignedTo = new SelectList(db.UserProfile, "UserId", "UserName", tasks.AssignedTo);
            ViewBag.RequestedBy = new SelectList(db.UserProfile, "UserId", "UserName", tasks.RequestedBy);
            return View(tasks);
        }
 public void MarkAsModified(Tasks item)
 {
     Entry(item).State = EntityState.Modified;
 }