public ActionResult Create([Bind(Include = "Id,Name,Photo,Address,DOB,Designation_Id,Pan,Aadhar,Phno,Fingerprint,Dept_Id,Qualification,Pub_No,Prev_Exp,Events,Project_Id")] Teacher teacher) { if (ModelState.IsValid) { db.Teachers.Add(teacher); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(teacher)); }
public ActionResult Create([Bind(Include = "LeaveID,ID,LeaveDescription,TempContact,StartDate,EndDate,LeaveType,LeaveTypeCount,TotalLeaveCount")] Leave leave) { if (ModelState.IsValid) { db.Leaves.Add(leave); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(db.Teachers, "Id", "Name", leave.ID); return(View(leave)); }
public ActionResult ApplyLeave([Bind(Include = "LeaveID,ID,LeaveDescription,TempContact,StartDate,EndDate,LeaveType,LeaveTypeCount,TotalLeaveCount")] Leave leave) { if (ModelState.IsValid) { leave.ID = User.Identity.Name; leave.Status = "Pending"; db.Leaves.Add(leave); leave.LeaveTypeCount = leave.LeaveTypeCount + getdays(leave.StartDate, leave.EndDate); db.SaveChanges(); return(RedirectToAction("AppSuccess")); } ViewBag.ID = new SelectList(db.Teachers, "Id", "Name", leave.ID); return(View(leave)); }
public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User user) { bool Status = false; string message = ""; if (ModelState.IsValid) { //check if email exists var exists = EmailExists(user.Email); if (exists) { ModelState.AddModelError("EmailExist", "Email already exists"); return(View(user)); } //generate activation code user.ActivationCode = Guid.NewGuid(); //Password Hashing user.Password = Encrypt.Hash(user.Password); user.ConfirmPassword = Encrypt.Hash(user.ConfirmPassword); user.IsEmailVerified = false; //save to database using (LeaveDBEntities db = new LeaveDBEntities()) { db.Users.Add(user); db.SaveChanges(); //send email SendVerificationLink(user.Email, user.ActivationCode.ToString()); message = "Registration successfully done. Account activation link has been sent to your email id " + user.Email; Status = true; } } else { message = "Invalid Request"; } ViewBag.Message = message; ViewBag.Status = Status; return(View(user)); }
public ActionResult VerifyAccount(string id) { bool Status = false; using (LeaveDBEntities db = new LeaveDBEntities()) { db.Configuration.ValidateOnSaveEnabled = false; var v = db.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault(); if (v != null) { v.IsEmailVerified = true; db.SaveChanges(); Status = true; } else { ViewBag.message = "Invalid Request"; } } ViewBag.Status = Status; return(View()); }