public ActionResult Index(FormCollection objForm) { UserDataLayer objUserDataLayer = new UserDataLayer(); bool isChecked = false; if (Request.Form["remember"] != null) { isChecked = true; } if (objUserDataLayer.AuthenticateUser(Request.Form["USer name"].ToString(), Request.Form["password"].ToString())) { FormsAuthentication.SetAuthCookie(Request.Form["USer name"].ToString(), isChecked); Session["IsPolice"] = objUserDataLayer.GetIsPoliceStatus(Request.Form["USer name"].ToString()); if (Request.QueryString["returnUrl"] != "" && Request.QueryString["returnUrl"] != null) { string sdf = Request.QueryString["returnUrl"]; return(Redirect(Request.QueryString["returnUrl"])); } FormsAuthentication.RedirectFromLoginPage(Request.Form["USer name"].ToString(), isChecked); ViewBag.UserName = System.Web.HttpContext.Current.User.Identity.Name; return(RedirectToAction("index", "Home")); } else { ViewBag.Status = "unauthorized"; ViewBag.Message = "Your crime details has been successfully sent to the department"; return(View()); } }
public bool SaveCrime(CrimeModel ObjCrimeObject, int IsWomensCrime) { using (SqlConnection con = new SqlConnection(SqlConnect.GetConnection)) { try { con.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO tblCrime (Crime,Description,Criminal,Location,IsWomensCrime,UserId) VALUES (@Crime,@Description,@Criminal,@Location,@IsWomensCrime,@Userid)", con); cmd.Parameters.AddWithValue("@Crime", ObjCrimeObject.Crime); cmd.Parameters.AddWithValue("@Description", ObjCrimeObject.Description); cmd.Parameters.AddWithValue("@Criminal", ObjCrimeObject.Criminal); cmd.Parameters.AddWithValue("@Location", ObjCrimeObject.Location); cmd.Parameters.AddWithValue("@IsWomensCrime", IsWomensCrime); cmd.Parameters.AddWithValue("@Userid", UserDataLayer.GetUserIdByEmail(System.Web.HttpContext.Current.User.Identity.Name)); cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { con.Close(); } } return(true); }
public ActionResult Index(FormCollection frmCollection) { UserModel objUserModel = new UserModel { EmailId = frmCollection["EmailId"].ToString(), Password = frmCollection["Password"].ToString(), ContactNo = frmCollection["contact"].ToString(), District = frmCollection["dist"].ToString() }; UserDataLayer objData = new UserDataLayer(); try { ViewBag.Status = "success"; ViewBag.Message = objData.UserRegistration(objUserModel); ViewBag.Message = "You are successfully registered to crime detection"; } catch (Exception) { ViewBag.Status = "error"; } return(View()); }
public ActionResult ViewUser() { UserDataLayer objData = new UserDataLayer(); List <User> ListUser = objData.GetUsers(); return(View(ListUser)); }
protected void DoSignUp(PasswordBox box) { user.PasswordHash = DefaultViewModel.GetHashString(box.Password); if (IsValidEmail(user.Email)) { UserDataLayer Layer = new UserDataLayer(); User fromDb = Layer.GetOne(user.Email); if (fromDb.Email == null) { Layer.Create(user); MailMessage message = new MailMessage() { Subject = "Bienvenue chez Bon App !", Body = "Merci d'avoir créé votre compte BonApp !\n\n" + "Vos identifiants :\n" + $"\tE-mail : \t{user.Email}" + $"\tMot de passe : \t{box.Password}", From = new MailAddress("*****@*****.**") }; message.To.Add(user.Email); DefaultViewModel.SendMail(message); MessageBox.Show("Votre compte a bien été créé. Vous allez recevoir un e-mail de confirmation."); RedirectEvent?.Invoke(new Login()); } else { MessageBox.Show("L'adresse e-mail spécifiée est déjà liée à un compte."); } } else { MessageBox.Show("L'adresse e-mail spécifiée n'est pas valide."); } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { UserDetails user1 = new UserDetails { Username = model.Fname + " " + model.Lname, Email = model.Email, Fname = model.Fname, Lname = model.Lname, Zipcode = model.Zipcode, Isdonor = model.Isdonor, Sname = model.Sname, Szip = model.Szip }; var user = new ApplicationUser { UserName = model.Email, Email = model.Email, Fname = model.Fname, Lname = model.Lname, Zipcode = model.Zipcode, Isdonor = model.Isdonor, Sname = model.Sname, Szip = model.Szip }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); UserDataLayer ur = new UserDataLayer(); ur.AddUser(user1); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Index() { UserDataLayer ObjUserDataLayer = new UserDataLayer(); List <User> ListUser = ObjUserDataLayer.GetUsers(); return(View(ListUser)); }
public void Setup(BenchmarkContext context) { IUserDataLayer _userRepo = new UserDataLayer(); IProjectDataLayer _projectRepo = new ProjectDataLayer(); ITaskDataLayer _taskRepo = new TaskDataLayer(); _userService = new UserBL(_userRepo); _projectService = new ProjectBL(_projectRepo); _taskService = new TaskBL(_taskRepo); _newTask = new TaskEntity { TaskName = "Perf Test Task", ParentId = 1, Priority = 10, StartDate = "11/01/2018", EndDate = "11/11/2018", ProjectId = 2, UserId = 1234567 }; }
public override void OnActionExecuting(ActionExecutingContext filterContext) { string UserName = System.Web.HttpContext.Current.User.Identity.Name; UserDataLayer objUserDataLayer = new UserDataLayer(); bool IsPolice = objUserDataLayer.GetIsPoliceStatus(UserName); if (IsPolice) { base.OnActionExecuting(filterContext); } else { filterContext.Result = new RedirectResult(string.Format("/Error/Index")); } }
public ActionResult IndexPost() { UserDataLayer dataLayer = new UserDataLayer(); if (dataLayer.AuthenticateUser(Request.Form["Username"].ToString(), Request.Form["password"].ToString())) { FormsAuthentication.RedirectFromLoginPage(Request.Form["Username"].ToString(), false); return(RedirectToAction("Index", "TaxiSearch")); } else { ViewBag.Message = "Invalid credentails"; return(RedirectToAction("Index", "UnAuthorized")); } }
public ActionResult Create(Patient patient) { if (!ModelState.IsValid) { return(View(patient)); } if (!UserDataLayer.CheckEmail(patient.PatientUser.Email)) { ModelState.AddModelError("PatientUser.Email", "Email already exists"); return(View(patient)); } patient.PatientUser.Role = Models.Enum.Role.Patient; patientBusinessLayer.AddPatient(patient); Logging.loggInfo($"Patient addedd with User id = {patient.PatientUser.Id} and Name = {patient.PatientUser.Name}"); return(RedirectToAction("Index")); }
public ActionResult Index(FormCollection frmCollection) { UserDataLayer userData = new UserDataLayer(); if (userData.UserAuthenticate(frmCollection["UserName"].ToString(), frmCollection["Password"].ToString())) { FormsAuthentication.RedirectFromLoginPage(frmCollection["UserName"].ToString(), false); FormsAuthentication.SetAuthCookie(frmCollection["UserName"].ToString(), false); string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; return(RedirectToAction("ShowRoute", "Home")); } else { ViewBag.Error = "Invalid user"; } return(View()); }
public ActionResult Index(FormCollection frmCollection) { bool IsDriver = false; if (Request.Form["IsDriver"] != null) { IsDriver = true; } if (frmCollection["passwd"].ToString() == frmCollection["cnfPassword"].ToString()) { User ObjUser = new User(); ObjUser.FirstName = frmCollection["firstname"]; ObjUser.LastName = frmCollection["lastname"]; ObjUser.Email = frmCollection["email"]; ObjUser.Password = frmCollection["passwd"]; ObjUser.IsDriver = IsDriver; ObjUser.LisenceNo = 2323; UserDataLayer UserDataLayer = new UserDataLayer(); UserReponse Response = UserDataLayer.InsertUserAndGetResponse(ObjUser); if (Response.ResultCode == ResultCodes.Error) { ViewBag.InfoError = Response.Message; } else if (Response.ResultCode == ResultCodes.Exists) { ViewBag.InfoMessage = Response.Message; } else if (Response.ResultCode == ResultCodes.Success) { ViewBag.InfoMessage = Response.Message; } } else { ViewBag.InfoError = "Password doesnt Match!!!"; } return(View()); }
public ActionResult Create(Nurse nurse) { if (!ModelState.IsValid) { return(View(nurse)); } if (!UserDataLayer.CheckEmail(nurse.NurseUser.Email)) { ModelState.AddModelError("NurseUser.Email", "Email already exists"); return(View(nurse)); } nurse.NurseUser.Role = Models.Enum.Role.Nurse; nurseBusinessLayer.AddNurse(nurse); Logging.loggInfo($"Nurse addedd with id = {nurse.NurseUser.Id} and Name = {nurse.NurseUser.Name}"); return(RedirectToAction("Index")); }
public ActionResult Store() { String user = User.Identity.GetUserName(); UserDataLayer uctx = new UserDataLayer(); UserDetails usrdtls = uctx.getUser(user); EdibleDataLayer ectx = new EdibleDataLayer(); //List<string> NearByZipCodes = new List<string>(); List <Edible> StoresAround1 = new List <Edible>(); if (!string.IsNullOrEmpty(usrdtls.Zipcode.ToString())) { List <Edible> StoresAround = ectx.GetEdiblePages(usrdtls.Zipcode.ToString()); StoresAround1 = StoresAround; } return(View(StoresAround1)); }
protected override void OnActionExecuted(ActionExecutedContext filterContext) { if (User != null) { var username = User.Identity.Name; if (!string.IsNullOrEmpty(username)) { String user = User.Identity.Name; UserDataLayer uctx = new UserDataLayer(); UserDetails usrdtls = uctx.getUser(user); //string fullName = string.Concat(new string[] { usrdtls.Fname, " ", usrdtls.Lname }); string fullName = ""; fullName = usrdtls.Fname + " " + usrdtls.Lname; ViewData.Add("FullName", fullName); } } base.OnActionExecuted(filterContext); }
protected void DoLogin(PasswordBox box) { UserDataLayer Layer = new UserDataLayer(); User fromDb = Layer.GetOne(user.Email); if (fromDb.Email == null) { MessageBox.Show("L'adresse e-mail n'a pas été reconnue."); } else if (fromDb.PasswordHash != DefaultViewModel.GetHashString(box.Password)) { MessageBox.Show("Mauvais mot de passe."); } else { _user = fromDb; Session.Instance().user = _user; RedirectEvent?.Invoke(new Acceuil()); } }
public ActionResult Create(Patient patient) { if (!ModelState.IsValid) { return(View(patient)); } PatientBusinessLayer patientUser = new PatientBusinessLayer(); if (!UserDataLayer.CheckEmail(patient.PatientUser.Email)) { ModelState.AddModelError("PatientUser.Email", "Email already exists"); Logging.loggError($"{patient.PatientUser.Email} is already exist as email"); return(View(patient)); } patient.PatientUser.Role = Models.Enum.Role.Patient; patientUser.AddPatient(patient); Logging.loggInfo($"Patient addedd with id = {patient.PatientUser.Id}"); return(Redirect("/Login/Index")); }
private void ClickOnLogin(object sender, RoutedEventArgs e) { _user.Password = ((PasswordBox)(sender as Button).CommandParameter).Password; UserDataLayer _layer = new UserDataLayer(); decimal? Id = _layer.SearchByLogin(_user.Login); if (Id.HasValue) { if (_layer.PasswordOK((int)Id, _user.Password)) { _user = _layer.GetOne((int)Id); MessageBox.Show($"Welcome aboard, {_user.Prenom} {_user.Nom}!"); } else { MessageBox.Show("Sorry, wrong password"); } } else { MessageBox.Show("Sorry, wrong login"); } }
private void DoLogin(PasswordBox box) { _user.Password = box.Password; UserDataLayer _layer = new UserDataLayer(); decimal? Id = _layer.SearchByLogin(_user.Login); if (Id.HasValue) { if (_layer.PasswordOK(Id.Value, _user.Password)) { _user = _layer.GetOne(Id.Value); MessageBox.Show($"Welcome aboard, {_user.Prenom} {_user.Nom}!"); } else { MessageBox.Show("Sorry, wrong password"); } } else { MessageBox.Show("Sorry, wrong login"); } }
public UserBusinessLayer() { userDataLayer = new UserDataLayer(); }
public ActionResult Index() { string CurrentUser = System.Web.HttpContext.Current.User.Identity.Name; CrimeDataLayer objCrimeDataLayer = new CrimeDataLayer(); List <CrimeModel> listCrime = objCrimeDataLayer.GetCrimeDetailsByUserId(UserDataLayer.GetUserIdByEmail(CurrentUser)); return(View(listCrime)); }