public ActionResult ChangeUserDetails(DiscussUser model)
        {
            if (!ModelState.IsValid)
            {
                return(View("UserDetails", model));
            }
            try
            {
                if (model != null)
                {
                    using (DISCUSSEntities dbcontext = new DISCUSSEntities())
                    {
                        var model1 = dbcontext.DiscussUsers.Where(t => t.id == model.id).FirstOrDefault();
                        dbcontext.DiscussUsers.Remove(model1);
                        dbcontext.DiscussUsers.Add(model);
                        dbcontext.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.StackTrace);
            }

            return(RedirectToAction("HomePage", "Home"));
        }
 public ActionResult UserDetails(DiscussUser model)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     try
     {
         if (model != null)
         {
             using (DISCUSSEntities dbcontext = new DISCUSSEntities())
             {
                 dbcontext.DiscussUsers.Add(model);
                 dbcontext.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         System.Console.Write(ex.StackTrace);
     }
     Session["Role"] = model.userrole;
     Session["Name"] = model.FirstName + " " + model.LastName;
     return(RedirectToAction("SearchGroups", "Home"));
 }
        public ActionResult UserDetails()
        {
            ViewBag.Title = "User Details";
            string username = Convert.ToString(Session["Username"]);
            //TempData["Username"] = string.Empty;
            DiscussUser emptyModelButId = new DiscussUser();

            emptyModelButId.id = GetIdForNewUser(username);
            return(View(emptyModelButId));
        }
        public ActionResult ChangeUserDetails()
        {
            int id = Convert.ToInt32(Session["id"]);

            DiscussUser model = new DiscussUser();

            try
            {
                using (DISCUSSEntities dbcontext = new DISCUSSEntities())
                {
                    model = dbcontext.DiscussUsers.Where(t => t.id == id).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.StackTrace);
            }

            return(View(model));
        }