public ActionResult PoliceCreate(tblreg re) { int model = de.tbllogins.Where(a => a.username == re.username).Count(); ViewBag.dist = de.tbldistricts.ToList(); ViewBag.cit = de.tblcities.ToList(); if (model == 0) { if (ModelState.IsValid) { tbllogin log = new tbllogin(); log.username = re.username; log.password = re.password; log.roleid = 3; log.isdeleted = false; log.status = false; de.tbllogins.Add(log); de.SaveChanges(); re.loginid = de.tbllogins.Max(a => a.loginid); de.tblregs.Add(re); de.SaveChanges(); } } else { TempData["dataalready"] = "Police user is already registered"; } return(RedirectToAction("../Home/Index")); }
public int Validateregister(LoginViewModel _model) { Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); var usrId = 0; try { var id = _idc.tbllogins.Where(a => a.Email == _model.Email || a.PhoneNumber == _model.phoneNumber).ToList(); if (id.Count() == 0) { tbllogin login = new tbllogin { CreatedDate = DateTime.Now, Email = _model.Email, FirstName = _model.firstname, IsActive = "Y", LastName = _model.lastname, Password = _model.Password, PhoneNumber = _model.phoneNumber }; _idc.tbllogins.InsertOnSubmit(login); _idc.SubmitChanges(); usrId = login.UserId; } } catch (Exception ex) { return(0); } finally { _idc.Dispose(); } return(usrId); }
public string UpdateProfile(tbllogin _profile, string Image = null) { string msg = "Profile Updated Succesfully"; Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var person = _idc.tbllogins.Where(a => a.UserId == _profile.UserId).FirstOrDefault(); if (!string.IsNullOrEmpty(Image)) { person.Image = Image; } person.FirstName = _profile.FirstName; person.LastName = _profile.LastName; person.Address = _profile.Address; person.Company = _profile.Company; person.Email = _profile.Email; person.IsActive = "Y"; person.Occupation = _profile.Occupation; person.Password = _profile.Password; person.PhoneNumber = _profile.PhoneNumber; _idc.SubmitChanges(); } catch (Exception ex) { msg = "Error " + ex.Message; } finally { _idc.Dispose(); } return(msg); }
public ActionResult Registration(tblRegistration registrationView) { bool statusRegistration = false; string messageRegistration = string.Empty; if (ModelState.IsValid) { // Email Verification //string userName = Membership.GetUserNameByEmail(registrationView.Email); //if (!string.IsNullOrEmpty(userName)) //{ // ModelState.AddModelError("Warning Email", "Sorry: Email already Exists"); // return View(registrationView); //} //Save User Data using (WebAuthenticationEntities dbContext = new WebAuthenticationEntities()) { var user = new tblRegistration() { Username = registrationView.Username, FirstName = registrationView.FirstName, LastName = registrationView.LastName, Email = registrationView.Email, Password = registrationView.Password, ConfirmPassword = registrationView.ConfirmPassword, // ActivationCode = Guid.NewGuid(), ID = registrationView.ID, }; var login = new tbllogin() { ID = registrationView.ID, Username = registrationView.Username, Password = registrationView.Password, Role = null, }; dbContext.tbllogins.Add(login); dbContext.tblRegistrations.Add(user); dbContext.SaveChanges(); //dbContext.Entry(user).State = System.Data.Entity.EntityState.Modified; // context.Entry(foo).State = EntityState.Modified; // context.SaveChanges(); //dbContext.SaveChanges(); } //Verification Email // VerificationEmail(registrationView.Email, registrationView.ActivationCode.ToString()); messageRegistration = "Your account has been created successfully."; statusRegistration = true; } else { messageRegistration = "Something Wrong!"; } ViewBag.Message = messageRegistration; ViewBag.Status = statusRegistration; return(View(registrationView)); }
public ActionResult DeleteConfirmed(int id) { tbllogin tbllogin = db.tbllogin.Find(id); db.tbllogin.Remove(tbllogin); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EditProfile(tbllogin log) { tbllogin logs = de.tbllogins.Where(a => a.loginid == log.loginid).SingleOrDefault(); logs.username = log.username; logs.password = log.password; de.SaveChanges(); return(Json(new { result = true, message = "Profile Updated Succesfully." }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "Uid,BadgeNumber,UserName,pass,endloginTime,persianName,UEnable")] tbllogin tbllogin) { if (ModelState.IsValid) { db.Entry(tbllogin).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbllogin)); }
public ActionResult Create([Bind(Include = "Uid,BadgeNumber,UserName,pass,endloginTime,persianName,UEnable")] tbllogin tbllogin) { if (ModelState.IsValid) { db.tbllogin.Add(tbllogin); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbllogin)); }
// GET: tbllogins/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbllogin tbllogin = db.tbllogin.Find(id); if (tbllogin == null) { return(HttpNotFound()); } return(View(tbllogin)); }
public ActionResult Login(tbllogin model, string returnurl) { try { WebAuthenticationEntities webAuthenticationEntities = new WebAuthenticationEntities(); var dataitem = webAuthenticationEntities.tbllogins.Where(x => x.Username == model.Username && x.Password == model.Password).FirstOrDefault(); if (dataitem != null) { FormsAuthentication.SetAuthCookie(dataitem.Username, false); if (Url.IsLocalUrl(returnurl) && returnurl.Length > 1 && returnurl.StartsWith("/") && !returnurl.StartsWith("//") && !returnurl.StartsWith("/\\")) { return(Redirect(returnurl)); } else { if (dataitem.Role == "Create") { return(RedirectToAction("Registration")); } else if (dataitem.Role == "Read") { return(RedirectToAction("Read")); } else if (dataitem.Role == "Update") { return(RedirectToAction("EditView")); } else if (dataitem.Role == "Delete") { return(RedirectToAction("Deleteview")); } else { return(RedirectToAction("Index")); } } } else { ModelState.AddModelError("", "Something Wrong : Username or Password invalid !!"); return(View()); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult UpdateEditPro(tblreg re) { tbllogin lg = de.tbllogins.Where(a => a.loginid == re.loginid).SingleOrDefault(); lg.username = re.username; lg.password = re.password; de.SaveChanges(); tblreg reg = de.tblregs.Where(a => a.regid == re.regid).SingleOrDefault(); reg.email = re.email; reg.address = re.address; reg.districtid = re.districtid; reg.cityid = re.cityid; de.SaveChanges(); return(Json(new { result = true, message = "Data Updated Succesfully." }, JsonRequestBehavior.AllowGet)); }
public ActionResult Login(tbllogin model) { if (ModelState.IsValid) { tbllogin data = db.tbllogins.Where(x => x.username.Equals(model.username) && x.password.Equals(model.password)).FirstOrDefault(); if (data != null) { return(RedirectToAction("Dashboard")); } else { ViewBag.ErrorMessage = "Username and Password Mismatch"; return(View(model)); } } return(View(model)); }
public ActionResult DeleteConfirmed(int?id) { try { tblRegistration tblRegistration = entities.tblRegistrations.Find(id); entities.tblRegistrations.Remove(tblRegistration); tbllogin tbllogin = entities.tbllogins.Find(id); entities.tbllogins.Remove(tbllogin); entities.SaveChanges(); return(RedirectToAction("Deleteview")); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult MyProfile(tbllogin user, HttpPostedFileBase file) { string Image = string.Empty; userServices _ser = new userServices(); if (file != null) { string path = Path.Combine(Server.MapPath("~/assets/images/users"), file.FileName); file.SaveAs(path); Image = "/assets/images/users/" + file.FileName; user.Image = Image; Session["image"] = Image; } var msg = _ser.UpdateProfile(user, Image); user = _ser.GetLoginUser(user.UserId); ViewData["msg"] = msg; return(View(user)); }
public ActionResult Login(tbllogin log) { ViewBag.message = ""; var logdetails = de.tbllogins.Where(a => a.username == log.username && a.password == log.password && a.isdeleted == false && a.status == true).ToList(); if (logdetails.Count > 0) { Session["logid"] = logdetails[0].loginid; if (logdetails[0].roleid == 1) { return(RedirectToAction("../Admin/AdminHome")); } else if (logdetails[0].roleid == 2) { return(RedirectToAction("../VehicleReg/RTOhome")); } else if (logdetails[0].roleid == 3) { return(RedirectToAction("../PoliceComplientReg/PoliceHome")); } else if (logdetails[0].roleid == 4) { return(RedirectToAction("../InsuranceReg/InsuranceHome")); } else if (logdetails[0].roleid == 5) { return(RedirectToAction("../PollutionReg/PollutionHome")); } else if (logdetails[0].roleid == 6) { return(RedirectToAction("../ServiceReg/ServiceHome")); } } else { TempData["dataalready"] = "Invalid Username or Password!"; } return(RedirectToAction("../Home/Index")); }
public ActionResult Register(tbllogin model) { if (ModelState.IsValid) { if (db.tbllogins.Where(x => x.username.Equals(model.username) && x.password.Equals(model.password)).Any()) { ViewBag.ErrorMessage = "User already exists!"; return(View()); } else { db.tbllogins.Add(model); db.SaveChanges(); return(RedirectToAction("Login")); } } else { ViewBag.ErrorMessage = "All fields are required"; return(View(model)); } }
public tbllogin GetLoginUser(int userId) { tbllogin _profile = new tbllogin(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { _profile = _idc.tbllogins.Where(a => a.UserId == userId).FirstOrDefault(); if (string.IsNullOrEmpty(_profile.Image)) { _profile.Image = "~/assets/images/icon/staff.png"; } } catch (Exception ex) { } finally { _idc.Dispose(); } return(_profile); }