Пример #1
0
        public ActionResult RegisterList(string searchBy, string search, int?page)
        {
            List <User> list = db.Users.ToList();

            using (PuranoPustakEntities db = new PuranoPustakEntities())
            {
                var models = new User();
                models.UserProfiles = db.Users.ToList();
                if (searchBy == "UserName")
                {
                    models.UserProfiles = models.UserProfiles.Where(x => x.UserName.ToLower().StartsWith(search.ToLower())).ToList();
                    return(View(models));
                }
                else if (searchBy == "Email")
                {
                    models.UserProfiles = models.UserProfiles.Where(x => x.Email.ToLower().StartsWith(search.ToLower())).ToList();
                    return(View(models));
                }
                //else
                //{
                //    return View(models.UserProfiles.Where(x => x.UserName.StartsWith(search)).ToList());
                //}
                return(View(models));
            }
        }
Пример #2
0
 public ActionResult Edit(int id)
 {
     using (PuranoPustakEntities db = new PuranoPustakEntities())
     {
         var user = db.Users.Find(id);
         return(View(user));
     }
 }
Пример #3
0
 public ActionResult Delete(int id)
 {
     using (PuranoPustakEntities db = new PuranoPustakEntities())
     {
         var user = db.Users.Where(x => x.UserID == id).First();
         db.Users.Remove(user);
         db.SaveChanges();
     }
     return(RedirectToAction("RegisterList"));
 }
 public ActionResult Autherize(CustomLogin.Models.User user)
 {
     using (PuranoPustakEntities db = new PuranoPustakEntities())
     {
         var userLogin = db.Users.Where(x => x.UserName == user.UserName && x.Password == user.Password).FirstOrDefault();
         if (userLogin == null)
         {
             user.ErrorMessage = "Entered User Name or Password is incorrect!";
             return(View("Index", user));
         }
         else
         {
             Session["userID"]   = userLogin.UserID;
             Session["UserName"] = userLogin.UserName;
             Session["Email"]    = userLogin.Email;
             return(RedirectToAction("Index", "Dashboard"));
         }
     }
 }
Пример #5
0
 public ActionResult Edit(User model)
 {
     try
     {
         using (PuranoPustakEntities db = new PuranoPustakEntities())
         {
             var user = db.Users.Where(x => x.UserID == model.UserID).FirstOrDefault();
             user.UserName        = model.UserName;
             user.Email           = model.Email;
             user.Password        = model.Password;
             user.ConfirmPassword = user.Password;
             db.Users.AddOrUpdate(user);
             db.SaveChanges();
         }
         return(RedirectToAction("RegisterList"));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #6
0
 public ActionResult Register(User model)
 {
     using (PuranoPustakEntities db = new PuranoPustakEntities())
     {
         if (db.Users.Any(x => x.UserName == model.UserName))
         {
             ViewBag.DuplicateMessage = "User Name already exist!";
             return(View("Register", model));
         }
         else if (db.Users.Any(x => x.Email == model.Email))
         {
             ViewBag.DuplicateMessage = "Email already exist!";
             return(View("Register", model));
         }
         db.Users.Add(model);
         db.SaveChanges();
     }
     ModelState.Clear();
     ViewBag.SuccessMessage = "Registration Successfull";
     return(View("Register", new User()));
 }