public ActionResult ResetPassword(ResetPasswordModel model) { var message = ""; if (ModelState.IsValid) { using (FinalDatabaseEntities1 dc = new FinalDatabaseEntities1()) { var user = dc.Employees.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault(); if (user != null) { user.password = Crypto.Hash(model.NewPassword); user.ResetPasswordCode = ""; dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); message = "New Password has been successfully updated"; } } } else { message = "Something went wrong"; } ViewBag.Message = message; return(View(model)); }
public ActionResult ForgotPassword(string EmailId) { string message = ""; bool status = false; using (FinalDatabaseEntities1 dc = new FinalDatabaseEntities1()) { var acc = dc.Employees.Where(a => a.email_id == EmailId).FirstOrDefault(); if (acc != null) { string resetCode = Guid.NewGuid().ToString(); SendVerificationLinkEmail(acc.email_id, resetCode, "ResetPassword"); message = "Password Reset Link Successfully Sent to Your Mail Id"; dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); } else { ModelState.AddModelError("EmailExist", "Account Not Found with Provided mail Id Please Check the Mail Id and Try again"); } ViewBag.Message = message; } return(View()); }
public ActionResult Create(Room room) { bool Status = false; string message = ""; var isexists = IsNameExists(room.Vendor_Name); if (!isexists) { ModelState.AddModelError("Not exists", "Vendor Name does not exists"); return(View(room)); } string fileName = Path.GetFileNameWithoutExtension(room.ImageFile.FileName); string extension = Path.GetExtension(room.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; room.Image = "~/Image/" + fileName; fileName = Path.Combine(Server.MapPath("~/Image/"), fileName); room.ImageFile.SaveAs(fileName); using (FinalDatabaseEntities1 db = new FinalDatabaseEntities1()) { db.Rooms.Add(room); db.SaveChanges(); message = "Room details added successfully!"; Status = true; } ViewBag.Status = Status; ViewBag.Message = message; return(View(room)); }
public bool IsEmailExists(string email_id) { using (FinalDatabaseEntities1 fp = new FinalDatabaseEntities1()) { var c = fp.Employees.Where(a => a.email_id == email_id).FirstOrDefault(); return(c != null); } }
public bool IsNameExists(string name) { using (FinalDatabaseEntities1 fp = new FinalDatabaseEntities1()) { var c = fp.Vendors.Where(a => a.name == name).FirstOrDefault(); return(c != null); } }
public bool IsEmp_IdExists(int id) { using (FinalDatabaseEntities1 fp = new FinalDatabaseEntities1()) { var c = fp.Employees.Where(a => a.Emp_Id == id).FirstOrDefault(); return(c != null); } }
public bool IsRoomIdExists(int id) { using (FinalDatabaseEntities1 fp = new FinalDatabaseEntities1()) { var c = fp.Rooms.Where(a => a.room_id == id).FirstOrDefault(); return(c != null); } }
public ActionResult Registration([Bind(Exclude = "Is_PaymentDone,ActivationCode")] Booking booking) { bool Status = false; string Message = ""; //Model is valid or not if (ModelState.IsValid) { //Emp_Id exists or not var Emp_id = IsEmp_IdExists(booking.Emp_Id); if (!Emp_id) { ModelState.AddModelError("EmpId Not exists", "Employee Id does not exists"); return(View(booking)); } var Emp_Name = IsEmp_NameExists(booking.Emp_Name); if (!Emp_Name) { ModelState.AddModelError("EmpName Not exists", "Employee Name does not exists"); return(View(booking)); } var id_exists = IsRoomIdExists(booking.room_id); if (!id_exists) { ModelState.AddModelError("room id Not exists", "Room ID does not exists"); return(View(booking)); } var Emp_Email_ID = IsEmp_EmailExists(booking.Emp_Email_Id); if (!Emp_Email_ID) { ModelState.AddModelError("Emp_Email Not exists", "Employee Mail does not exists"); return(View(booking)); } booking.Is_PaymentDone = false; #region Save to database using (FinalDatabaseEntities1 fp = new FinalDatabaseEntities1()) { booking.Is_PaymentDone = true; fp.Bookings.Add(booking); fp.SaveChanges(); SendVerificationLinkEmail(booking.Emp_Email_Id, booking.ActivationCode.ToString()); Message = "Your Booking request has been sent to the admin.You will receive a mail whether booking is confirmed or not from the admin in a while"; Status = true; } #endregion } else { Message = "Invalid request"; } ViewBag.Message = Message; ViewBag.Status = Status; return(View(booking)); }
public ActionResult DeleteConfirmed(int id)//Delete booked room { string message = ""; FinalDatabaseEntities1 db = new FinalDatabaseEntities1(); Booking booking = db.Bookings.Find(id); db.Bookings.Remove(booking); db.SaveChanges(); message = "Your booking has been cancelled"; ViewBag.Message = message; return(View(booking)); }
public ActionResult Delete(int?id) //Delete booked room { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FinalDatabaseEntities1 db = new FinalDatabaseEntities1(); Booking booking = db.Bookings.Find(id); if (booking == null) { return(HttpNotFound()); } return(View(booking)); }
public ActionResult ConfirmBooking(string email) { string message = ""; Booking booking = new Booking(); using (FinalDatabaseEntities1 db = new FinalDatabaseEntities1()) { booking.IsBookingConfirmed = true; db.SaveChanges(); SendBookingConfirmedEmail(booking.Emp_Email_Id); message = "The meeting room booking is confirmed"; } ViewBag.Message = message; return(View(booking)); }
public ActionResult ResetPassword(string id) { using (FinalDatabaseEntities1 dc = new FinalDatabaseEntities1()) { var user = dc.Employees.Where(a => a.ResetPasswordCode == id).FirstOrDefault(); if (user != null) { ResetPasswordModel model = new ResetPasswordModel(); model.ResetCode = id; return(View(model)); } else { return(HttpNotFound()); } } }
public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] Employee e) { bool Status = false; string Message = ""; //Model is valid or not if (ModelState.IsValid) { #region//email already exists var isexists = IsEmailExists(e.email_id); if (isexists) { ModelState.AddModelError("Email exists", "Email already exists"); return(View(e)); } #endregion #region Generate Activation Code e.ActivationCode = Guid.NewGuid(); #endregion #region Password hashing e.password = Crypto.Hash(e.password); e.Confirm_password = Crypto.Hash(e.Confirm_password); #endregion e.IsEmailVerified = false; #region Save to database using (FinalDatabaseEntities1 fp = new FinalDatabaseEntities1()) { fp.Employees.Add(e); fp.SaveChanges(); SendVerificationLinkEmail(e.email_id, e.ActivationCode.ToString()); Message = "Registration successfully done.Account activation link" + " has been sent to your email_id " + e.email_id; Status = true; } #endregion } else { Message = "Invalid request"; } ViewBag.Message = Message; ViewBag.Status = Status; return(View(e)); }
public ActionResult Edit([Bind(Exclude = "Booking_Id,Emp_Id,Emp_Name,Emp_Email_Id,room_id,location,DateTime,Duration,Payment_money,Is_PaymentDone,ActivationCode")] Booking booking) { string message = ""; FinalDatabaseEntities1 db = new FinalDatabaseEntities1(); if (ModelState.IsValid) { db.Entry(booking).State = EntityState.Modified; db.SaveChanges(); message = "Booking has been confirmed"; } else { ModelState.AddModelError(" ", "Booking details cannot be edited"); } ViewBag.Message = message; return(View(booking)); }
public ActionResult Login(EmployeeLogin login, string ReturnUrl) { string message = ""; using (FinalDatabaseEntities1 dc = new FinalDatabaseEntities1()) { var c = dc.Employees.Where(a => a.email_id == login.email_id).FirstOrDefault(); if (c != null) { if (string.Compare(Crypto.Hash(login.password), c.password) == 0) { int timeout = login.RememberMe ? 525600 : 20; var ticket = new FormsAuthenticationTicket(login.email_id, login.RememberMe, timeout); string encrypted = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted); cookie.Expires = DateTime.Now.AddMinutes(timeout); cookie.HttpOnly = true; Response.Cookies.Add(cookie); return(RedirectToAction("Index")); /*if (Url.IsLocalUrl(ReturnUrl)) * { * return RedirectToAction("Index"); * } * else * { * return RedirectToAction("Login", "Employee"); * }*/ } else { //message = "Invalid credential provided ModelState.AddModelError("", "The username or password is incorrect"); } } else { //message = "Invalid credential provided"; ModelState.AddModelError("", "The username or password is incorrect"); } } //ViewBag.Message = message; return(View()); }
public ActionResult Login(Admin objUser) { if (ModelState.IsValid) { using (FinalDatabaseEntities1 db = new FinalDatabaseEntities1()) { if ((objUser.username.Equals("admin")) && (objUser.password.Equals("admin"))) { Session["username"] = objUser.username.ToString(); Session["password"] = objUser.password.ToString(); return(RedirectToAction("UserDashBoard")); } else { ModelState.AddModelError("", "The username or password is incorrect"); } } } return(View(objUser)); }
public ActionResult VerifyAccount(string id) { bool Status = false; using (FinalDatabaseEntities1 dc = new FinalDatabaseEntities1()) { dc.Configuration.ValidateOnSaveEnabled = false; var v = dc.Employees.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault(); if (v != null) { v.IsEmailVerified = true; dc.SaveChanges(); Status = true; } else { ViewBag.Message = "Invalid Request"; } } ViewBag.Status = Status; return(View()); }
public ActionResult Display() { FinalDatabaseEntities1 db = new FinalDatabaseEntities1(); return(View(db.Rooms.ToList())); }
public ActionResult Display()//Delete booked rooms for admin { FinalDatabaseEntities1 db = new FinalDatabaseEntities1(); return(View(db.Bookings.ToList())); }
public ActionResult Index()//To display booked rooms { FinalDatabaseEntities1 db = new FinalDatabaseEntities1(); return(View(db.Bookings.ToList())); }