public ActionResult Create([Bind(Include = "StudentId,OTP,OTP_Status,Id")] Student_Otp student_Otp)
        {
            if (ModelState.IsValid)
            {
                var    bookings = db.TemporaryBookings.ToList();
                Random r        = new Random();
                foreach (var item in bookings)
                {
                    if (student_Otp.CheckOTP() == false)
                    {
                        Guid guid   = new Guid();
                        var  userId = User.Identity.GetUserId();
                        student_Otp.StudentId  = guid.ToString() + r.Next(1, 100) + r.Next(100, 500);
                        student_Otp.OTP_Status = "Valid";
                        student_Otp.Id         = userId;
                        Bs.AddStudent_Otp(student_Otp);
                        return(RedirectToAction("Register1", "Account", new { Otp = student_Otp.OTP }));
                    }
                    else
                    {
                        TempData["message"] = "Invalid OTP";
                        return(RedirectToAction("Create"));
                    }
                }
            }

            return(View(student_Otp));
        }
        public ActionResult DeleteConfirmed(string id)
        {
            Student_Otp student_Otp = Bs.GetTStudent_Otp(id);

            Bs.RemoveStudent_Otp(student_Otp);
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "StudentId,OTP,OTP_Status")] Student_Otp student_Otp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student_Otp).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student_Otp));
 }
Пример #4
0
 public bool RemoveStudent_Otp(Student_Otp student_Otp)
 {
     try
     {
         db.Student_Otp.Remove(student_Otp);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     { return(false); }
 }
Пример #5
0
 public bool UpdateStudent_Otp(Student_Otp student_Otp)
 {
     try
     {
         db.Entry(student_Otp).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     { return(false); }
 }
        // GET: Student_Otp/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Student_Otp student_Otp = db.Student_Otp.Find(id);

            if (student_Otp == null)
            {
                return(HttpNotFound());
            }
            return(View(student_Otp));
        }
        // GET: Student_Otp/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Student_Otp student_Otp = Bs.GetTStudent_Otp(id);

            if (student_Otp == null)
            {
                return(HttpNotFound());
            }
            return(View(student_Otp));
        }