// // GET: /Admin/Create public ActionResult Create() { RegisteredUser RegisteredUser = new RegisteredUser(); SystemAdmin SystemAdmin = new SystemAdmin(); SystemAdmin.RegisteredUser = RegisteredUser; return View(SystemAdmin); }
// GET: GeneralUsers/Create public ActionResult Create() { if (System.Web.HttpContext.Current.User.IsInRole("Admin") || System.Web.HttpContext.Current.User.IsInRole("GeneralUser") || System.Web.HttpContext.Current.User.IsInRole("Applicant") || System.Web.HttpContext.Current.User.IsInRole("GeneralUser")) { return RedirectToAction("Index", "Home"); } RegisteredUser registeredUser = new RegisteredUser(); GeneralUser generalUser = new GeneralUser(); generalUser.RegisteredUser = registeredUser; return View(generalUser); }
public ActionResult Index() { List<Applicant> applicantList = new List<Applicant>(); foreach (var applicant in db.Applicants) { RegisteredUser registeredUser = new RegisteredUser(); registeredUser = db.RegisteredUsers.Find(applicant.RegisteredUserRefId); applicant.RegisteredUser = registeredUser; applicantList.Add(applicant); } return View(db.Applicants.ToList()); }
public ActionResult Login(RegisteredUser model, string returnUrl) { using (UsersContext entities = new UsersContext()) { string username = model.UserName; string password = model.Password; Debug.AutoFlush = true; // Now if our password was enctypted or hashed we would have done the // same operation on the user entered password here, But for now // since the password is in plain text lets just authenticate directly var currentUser = entities.RegisteredUsers.SingleOrDefault(user => user.UserName == username); bool userValid=false; if (currentUser != null) { userValid = currentUser.UserName.Equals(username) && currentUser.Password.Equals(password); } // User found in the database if (userValid) { FormsAuthentication.SetAuthCookie(username, false); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { UsersContext db = new UsersContext(); RegisteredUser registeredUser = new UsersContext().RegisteredUsers.SingleOrDefault(user => user.UserName == username); registeredUser.IsActivated = "Yes"; db.Entry(registeredUser).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index", "Home"); } } else { ModelState.AddModelError("", "আপনার নাম অথবা পাসওয়ার্ডটি ভুল হয়েছে."); } } // If we got this far, something failed, redisplay form return View(model); }
// GET: GeneralUsers/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } GeneralUser generalUser = db.GeneralUsers.Find(id); RegisteredUser registeredUser = new RegisteredUser(); registeredUser = db.RegisteredUsers.SingleOrDefault(user=>user.RegisteredUserID==generalUser.RegisteredUserRefId); generalUser.RegisteredUser = registeredUser; if (generalUser == null) { return HttpNotFound(); } return View(generalUser); }
public ActionResult Create(Post post) { String userName = System.Web.HttpContext.Current.User.Identity.Name; RegisteredUser registeredUser = new RegisteredUser(); registeredUser = db.RegisteredUsers.SingleOrDefault(user => user.UserName == userName); Post posts = new Post(); posts.RegisteredUser = registeredUser; post.RegisteredUserRefId = posts.RegisteredUser.RegisteredUserID; if (ModelState.IsValid) { post.Date = DateTime.Now; post.VoteCounter = 0; db.Posts.Add(post); db.SaveChanges(); return RedirectToAction("Index","Home"); } return View(post); }
public ActionResult Edit(int id = 0) { Applicant applicant = db.Applicants.Find(id); RegisteredUser registeredUser = new RegisteredUser(); registeredUser = db.RegisteredUsers.SingleOrDefault(user=>user.RegisteredUserID==applicant.RegisteredUserRefId); ReferencedPerson referencedPerson = new ReferencedPerson(); referencedPerson = db.ReferencedPerson.SingleOrDefault(user=>user.ReferencedPersonId==applicant.ReferencedPersonRefId); applicant.RegisteredUser = registeredUser; applicant.ReferencedPerson = referencedPerson; if (applicant == null) { return HttpNotFound(); } return View(applicant); }
public ActionResult Create(Applicant applicant) { String[] VWorker = { "Driver", "Helper", "Conductor", "Vehicle Technician" }; String[] HWorker = { "House worker" }; String[] HKeeper = { "Housekeeper" }; String[] SMan = { "Grocery salesman", "Medical Salesman", "Cosmetics and Ornaments Salesman", "Salesman of Furniture and Vehicles" }; String[] FWorker = { "Garment Worker", "Agricultural and Food Factory Worker", "Mechanics", "Pharmaceuticals Factory Worker" }; String[] AWorker = { "Farmers" }; String[] Others = { "Others" }; if (VWorker.Contains(applicant.Subcategory)) { applicant.Category = "Vehicle Worker"; } else if (HWorker.Contains(applicant.Subcategory)) { applicant.Category = "House worker"; } else if (HKeeper.Contains(applicant.Subcategory)) { applicant.Category = "Housekeeper"; } else if (SMan.Contains(applicant.Subcategory)) { applicant.Category = "Salesman"; } else if (FWorker.Contains(applicant.Subcategory)) { applicant.Category = "Factory Worker"; } else if (AWorker.Contains(applicant.Subcategory)) { applicant.Category = "Agricultural Worker"; } else if (Others.Contains(applicant.Subcategory)) { applicant.Category = "Others"; } var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); if (!HasImageExtension(fileName)) { } else { var path = Path.Combine(Server.MapPath("~/Images/"), fileName); applicant.Photo = path; file.SaveAs(path); } } var NationalIdCard = Request.Files[1]; if (NationalIdCard != null && NationalIdCard.ContentLength > 0) { var fileName = Path.GetFileName(NationalIdCard.FileName); if (!HasImageExtension(fileName)) { } else { var path = Path.Combine(Server.MapPath("~/Images/"), fileName); applicant.NationalIdCard = path; NationalIdCard.SaveAs(path); } } if (ModelState.IsValid) { RegisteredUser user = new RegisteredUser(); user.Name = applicant.Name; user.PhoneNo = applicant.PhoneNo; user.Password = CreateRandomPassword(5); user.UserName = applicant.Name + CreateRandomPassword(3); user.confirmPassword = user.Password; user.IsActivated = "Yes"; applicant.RegisteredUser = user; applicant.IsVerified = 0; TempData["applicant"] = applicant; //return File("~/Content/myPdf.pdf", "application/pdf", Server.UrlEncode("myPdf.pdf")); TempData["code"] = applicant.sendSms(applicant.PhoneNo); TempData.Keep(); return RedirectToAction("GetVerified"); } return RedirectToAction("Create"); }
public ActionResult Edit(RegisteredUser registereduser) { if (ModelState.IsValid) { db.Entry(registereduser).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(registereduser); }
public ActionResult Create(RegisteredUser registereduser) { if (ModelState.IsValid) { registereduser.IsActivated = "Yes"; db.RegisteredUsers.Add(registereduser); db.SaveChanges(); return RedirectToAction("Index"); } return View(registereduser); }