Beispiel #1
0
        public ActionResult Deleteuser(string userid)
        {
            try
            {
                if (!string.IsNullOrEmpty(userid))
                {
                    Guid userguid = new Guid(userid);
                    var  userdata = context.aspnet_Users.Where(x => x.UserId == userguid).ToList();
                    if (userdata != null && userdata.Count() > 0)
                    {
                        var username = userdata.FirstOrDefault().UserName;
                        context.SPDeleteUser(userguid, username);
                        context.SaveChanges();
                        TempData["Message"] = "User Deleted";
                    }
                    else
                    {
                        TempData["Message"] = "User Not Exist";
                    }
                }
                else
                {
                    TempData["Message"] = "User Not Found";
                }
            }
            catch (Exception ex)
            {
                cm.ErrorExceptionLogingByService(ex.ToString(), "ManageUser" + ":" + new StackTrace().GetFrame(0).GetMethod().Name, "Deleteuser", "NA", "NA", "NA", "WEB");
            }

            return(RedirectToAction("Index"));
        }