Example #1
0
        public ActionResult Index(StatusUpdate model)
        {
            if (ModelState.IsValid)
            {
                using (StatusDbDataContext db = new StatusDbDataContext())
                {

                    var userName = User.Identity.Name;
                    db.Status.InsertOnSubmit(new Status { UserStatus = model.Status, Username = userName, StatusDateCreated = DateTime.Now });
                    db.SubmitChanges();
                    return RedirectToAction("Index");
                }
            }

            return View(model);
        }
Example #2
0
 public ActionResult Index()
 {
     var userName = User.Identity.Name;
     using (StatusDbDataContext db = new StatusDbDataContext())
     {
         ViewBag.StatusUpdates = db.Status
             .Where(s => s.Username == userName)
             .OrderByDescending(s => s.StatusDateCreated)
             .Select(s => new StatusUpdate
                 {
                     StatusDate = s.StatusDateCreated,
                     Status = s.UserStatus
                 }).ToList();
     }
     return View();
 }