예제 #1
0
        public string SaveInformationIntoDb(Registation registation)
        {
            string insertSql = "INSERT INTO tbl_user (";

            insertSql += "user_id, user_pass, user_email, user_type,retryAttemps,isLocked) ";
            insertSql += "VALUES (";
            insertSql += "@userid, @userpass, @useremail, @usertype,@retryAttemps,@isLocked)";

            ConnectionObj.Open();
            CommandObj.CommandText = insertSql;
            CommandObj.Parameters.AddWithValue("@userid", registation.UserId);
            CommandObj.Parameters.AddWithValue("@userpass", registation.Password);
            CommandObj.Parameters.AddWithValue("@useremail", registation.Email);
            CommandObj.Parameters.AddWithValue("@usertype", registation.Type);
            CommandObj.Parameters.AddWithValue("@retryAttemps", registation.RetryAttemps);
            CommandObj.Parameters.AddWithValue("@isLocked", registation.Islocked);

            int saveRowAffected = CommandObj.ExecuteNonQuery();

            ConnectionObj.Close();
            if (saveRowAffected > 0)
            {
                return("success");
            }
            return("Save Failed");
        }
예제 #2
0
        public IActionResult Registration(RegistrationViewModel model)
        {
            if (ModelState.IsValid)
            {
                string password = model.CandidateName.Substring(0, 4).ToUpper() + model.Mobile.Substring(0, 4);

                Console.WriteLine(password);
                Registation registation = new Registation()
                {
                    CandidateName      = model.CandidateName,
                    Email              = model.Email,
                    Mobile             = model.Mobile,
                    ExaminationApplied = model.ExaminationApplied,
                    Password           = password
                };

                bool status = _repositry.Add(registation);
                if (status)
                {
                    Registation reg = _repositry.GetRegistationById(model.Email);
                    TempData.Add("Reg", reg.Registration_number);
                    TempData.Add("Password", reg.Password);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View(new RegistrationViewModel()));
        }
예제 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["User"] != null)
         {
             _registation       = (Registation)Session["User"];
             userNameLabel.Text = "User ID : " + _registation.UserId;
             rollLabel.Text     = "Roll No : " + _registation.UserId.Substring(_registation.UserId.Length - 3);
         }
         else
         {
             Response.Redirect("~/UI/Login.aspx");
         }
     }
     UserRList = _registationManager.GetUserDetail(_registation.UserId);
     foreach (var registation in UserRList)
     {
         UserList = _profileManager.GetInformationByUserId(registation.Id);
         foreach (var profile in UserList)
         {
             studentNameLabel.Text = profile.Name;
             studentImage.ImageUrl = profile.Image;
             classLabel.Text       = "Class : " + profile.ClassName + " (" + profile.ClassCode + ")";
             iconLabel.CssClass    = profile.Gender == "Male" ? "fa fa-male" : "fa fa-female";
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["User"] != null)
     {
         _registation = (Registation)Session["User"];
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("U_Id,Name,Email,Password,ConfirmPassword,Phone,Gender")] Registation registation)
        {
            if (id != registation.U_Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(registation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RegistationExists(registation.U_Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(registation));
        }
예제 #6
0
        protected void submitButton_Click(object sender, EventArgs e)
        {
            var registation = new Registation();

            registation.UserId       = userIdTextBox.Text;
            registation.Password     = FormsAuthentication.HashPasswordForStoringInConfigFile(passwordTextBox.Text, "SHA1");
            registation.Email        = emailTextBox.Text;
            registation.Type         = typeDropDownList.SelectedItem.Text;
            registation.RetryAttemps = 0;
            registation.Islocked     = false;

            bool isCaptchaValid = Session["CaptchaText"] != null && Session["CaptchaText"].ToString() == captchaTextBox.Text;

            if (isCaptchaValid)
            {
                string msg = _registationManager.RegistarNewUser(registation);
                if (msg == "success")
                {
                    Server.Transfer("Login.aspx?x=1&y=2");
                }
            }
            else
            {
                msgLabel.Text      = "Captcha Missmatch";
                msgLabel.ForeColor = Color.Red;
                msgLabel.Font.Size = 16;
            }
        }
예제 #7
0
        public List <Registation> GetAllInfo(string userId)
        {
            string selectSql = "SELECT * FROM tbl_user WHERE user_id ='" + userId + "'";

            ConnectionObj.Open();
            CommandObj.CommandText = selectSql;
            SqlDataReader reader = CommandObj.ExecuteReader();

            var userInfoList = new List <Registation>();

            while (reader.Read())
            {
                var registation = new Registation
                {
                    Id           = Convert.ToInt32(reader["id"].ToString()),
                    UserId       = reader["user_id"].ToString(),
                    Password     = reader["user_pass"].ToString(),
                    Type         = reader["user_type"].ToString(),
                    RetryAttemps = Convert.ToInt32(reader["retryAttemps"].ToString()),
                    Islocked     = Convert.ToBoolean(reader["isLocked"].ToString())
                };

                userInfoList.Add(registation);
            }
            reader.Close();
            ConnectionObj.Close();

            return(userInfoList);
        }
예제 #8
0
        public async Task <IActionResult> Registration([FromBody] Registation registation)
        {
            try
            {
                if (string.IsNullOrEmpty(registation.Mobile) || string.IsNullOrEmpty(registation.Email) || string.IsNullOrEmpty(registation.Password))
                {
                    return(new BadRequestObjectResult("Request not proper"));
                }

                var resultByMobileNumber = await _userProvider.GetByMobileNumberAsync(registation.Mobile);

                if (resultByMobileNumber != null)
                {
                    if (resultByMobileNumber.Id != Guid.Empty)
                    {
                        return(new BadRequestObjectResult("Mobile number already exits"));
                    }
                }


                var resultByEmail = await _userProvider.GetByEmailAsync(registation.Email);

                if (resultByEmail != null)
                {
                    if (resultByEmail.Id != Guid.Empty)
                    {
                        return(new BadRequestObjectResult("Email already exits"));
                    }
                }

                User user = new User();
                user.MobileNumber = registation.Mobile;
                user.Email        = registation.Email;
                user.Password     = registation.Password;
                user.CreatedOn    = DateTime.Now.ToUniversalTime();
                user.UpdatedOn    = DateTime.Now.ToUniversalTime();
                user.CreatedBy    = DefultValueHelper.DEFAULT_SYSTEMUSER;
                user.UpdatedBy    = DefultValueHelper.DEFAULT_SYSTEMUSER;
                user.IsActive     = false;
                await _userProvider.AddAsync(user);

                Guid userid = user.Id;

                if (userid != Guid.Empty)
                {
                    OTP objOTP = await InsertNewOTP(userid, "STS");

                    if (objOTP.Id != Guid.Empty && !string.IsNullOrEmpty(user.Email))
                    {
                        await _IEmailHelper.SendEmail(new EmailData { FromEmails = DefultValueHelper.DEFAULT_FROM_EMAIL, ToEmails = user.Email, Subject = "Access code for portal", Body = objOTP.Code });
                    }
                }
                return(new OkResult());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #9
0
        public IActionResult Enroll(EnrollmentViewModel model)
        {
            string registration_num = HttpContext.Session.GetString("UserName");

            if (registration_num == null)
            {
                TempData["EnrollSession"] = "Session Expired !";
                return(RedirectToAction("Login", "Account"));
            }
            if (ModelState.IsValid)
            {
                //string path = model.Profile.FileName;
                //string path2 = model.Signature.FileName;

                double ImageInKB = model.Profile.Length / 1024;

                string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "images");
                string uniqueProfile = Guid.NewGuid().ToString() + "_" + model.Profile.FileName;
                string profilePath   = Path.Combine(uploadsFolder, uniqueProfile);

                string uniqueSignature = Guid.NewGuid().ToString() + "_" + model.Signature.FileName;
                string signaturePath   = Path.Combine(uploadsFolder, uniqueSignature);

                Registation registation = registerRepositry.GetRegistationByRegistration_num(HttpContext.Session.GetString("UserName"));
                Enrollment  enrollment  = new Enrollment()
                {
                    Name = registation.CandidateName,
                    Registration_number = registration_num,
                    DOB                   = model.DOB,
                    Sex                   = model.Sex,
                    Catagory              = model.Catagory,
                    ContactNumber         = registation.Mobile,
                    Email                 = registation.Email,
                    Father                = model.Father,
                    Mobile                = model.Mobile,
                    ParmanentAddress      = model.ParmanentAddress,
                    SameAsParmanent       = model.SameAsParmanent,
                    CorrespondanceAddress = model.CorrespondanceAddress,
                    Programm              = registation.ExaminationApplied,
                    ExameCenter           = model.centerCode,
                    Profile               = uniqueProfile,
                    Signature             = uniqueSignature
                };

                if (repositry.Add(enrollment))
                {
                    model.Profile.CopyTo(new FileStream(profilePath, FileMode.Create));
                    model.Profile.CopyTo(new FileStream(signaturePath, FileMode.Create));
                    TempData["Enroll"] = "Your are Enrolled !";
                }
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                EnrollmentViewModel enrollment = new EnrollmentViewModel();
                enrollment.ExameCenterCh1 = cernterRepositry.GetExamCenters();
                return(View(enrollment));
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Registation registation = db.Registationdb.Find(id);

            db.Registationdb.Remove(registation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,FirstName,LastName,Nic,Course_id,Batch_id,phoneno")] Registation registation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(registation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(registation));
 }
        public ActionResult Create([Bind(Include = "id,FirstName,LastName,Nic,Course_id,Batch_id,phone_no")] Registation registation)
        {
            if (ModelState.IsValid)
            {
                db.Registationdb.Add(registation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(registation));
        }
        public async Task <IActionResult> Create([Bind("U_Id,Name,Email,Password,ConfirmPassword,Phone,Gender")] Registation registation)
        {
            if (ModelState.IsValid)
            {
                _context.Add(registation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(registation));
        }
 public ActionResult Edit([Bind(Include = "Id,Name,Surname,CourseId,BatchId,Tel")] Registation registation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(registation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BatchId  = new SelectList(db.Batches, "Id", "Batch1", registation.BatchId);
     ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", registation.CourseId);
     return(View(registation));
 }
예제 #15
0
        protected void singInButton_Click(object sender, EventArgs e)
        {
            bool isCaptchaValid = Session["CaptchaText"] != null && Session["CaptchaText"].ToString() == captchaTextBox.Text;

            var registation = new Registation {
                UserId = userIdTextBox.Text, Password = passwordTextBox.Text
            };

            if (isCaptchaValid)
            {
                int msg = _registationManager.CheckingRequirements(registation);

                if (msg == 1)
                {
                    Session["User"] = registation;
                    Response.Redirect("Teachers/home.aspx");
                }
                else if (msg == 2)
                {
                    Session["User"] = registation;
                    Response.Redirect("Students/home.aspx");
                }
                else if (msg == 3)
                {
                    Session["User"] = registation;
                    Response.Redirect("Admin/home.aspx");
                }
                else if (msg == 0)
                {
                    msgLabel.Text      = "Password does not match";
                    msgLabel.ForeColor = Color.Red;
                    msgLabel.Font.Size = 16;
                }
                else if (msg == -2)
                {
                    msgLabel.Text      = "Account Blocked. Please contact administrator.";
                    msgLabel.ForeColor = Color.Red;
                    msgLabel.Font.Size = 16;
                }
                else
                {
                    msgLabel.Text      = "Invalid  UserID";
                    msgLabel.ForeColor = Color.Red;
                    msgLabel.Font.Size = 16;
                }
            }
            else
            {
                msgLabel.Text      = "Invalid Security Code";
                msgLabel.ForeColor = Color.Red;
                msgLabel.Font.Size = 16;
            }
        }
        public ActionResult Registation(Registation registation)
        {
            if (ModelState.IsValid)
            {
                _context.Registations.Add(registation);
                _context.SaveChanges();

                ModelState.Clear();
                ViewBag.Message = registation.Name + " " + registation.Email + " is successfully registered.";
            }
            return(View());
        }
 public string RegistarNewUser(Registation registation)
 {
     if (_registationGateway.IsUserIdExists(registation.UserId))
     {
         return("Sorry! Username already exists");
     }
     if (_registationGateway.IsUserEmailExists(registation.Email))
     {
         return("Sorry! Email already exists");
     }
     return(_registationGateway.SaveInformationIntoDb(registation));
 }
예제 #18
0
        //public bool SaveAll()
        //{

        //    //return dBWebData.SaveChanges() > 0;
        //}
        public void Add(Registation registation)
        {
            try
            {
                Console.WriteLine(registation.Email);
                repo.Registations.Add(registation);
                repo.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        // GET: Registations/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Registation registation = db.Registationdb.Find(id);

            if (registation == null)
            {
                return(HttpNotFound());
            }
            return(View(registation));
        }
예제 #20
0
 public bool UserExistes(string email, string mobile)
 {
     try
     {
         Registation registation = repo.Registations.FirstOrDefault(r => r.Email == email || r.Mobile == mobile);
         if (registation == null)
         {
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(true);
     }
 }
        public ActionResult LogIn(Registation registation)
        {
            var account = _context.Registations.Where(u => u.Name == registation.Name && u.Password == registation.Password).FirstOrDefault();

            if (account != null)
            {
                HttpContext.Session.SetString("U_Id", account.U_Id.ToString());
                HttpContext.Session.SetString("Name", account.Name);
                return(RedirectToAction("Welcome"));
            }
            else
            {
                ModelState.AddModelError("", "Username or password is wrong.");
            }
            return(View());
        }
        // GET: Registations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Registation registation = db.Registations.Find(id);

            if (registation == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BatchId  = new SelectList(db.Batches, "Id", "Batch1", registation.BatchId);
            ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", registation.CourseId);
            return(View(registation));
        }
예제 #23
0
        //protected int Tid;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                _registation = (Registation)Session["User"];
                UserList     = _registationManager.GetUserDetail(_registation.UserId);
                foreach (var detail in UserList)
                {
                    ViewState["Tid"] = detail.Id;
                }


                classDropDownList.DataSource     = _dropDownManager.GetAllClasses();
                classDropDownList.DataTextField  = "ClassName";
                classDropDownList.DataValueField = "Id";
                classDropDownList.DataBind();

                districtDropDownList.DataSource     = _dropDownManager.GetAllDistrict();
                districtDropDownList.DataTextField  = "DistrictName";
                districtDropDownList.DataValueField = "Id";
                districtDropDownList.DataBind();



                bloodGroupDropDownList.DataSource     = _dropDownManager.GetAllBloodGroup();
                bloodGroupDropDownList.DataTextField  = "GroupName";
                bloodGroupDropDownList.DataValueField = "Id";
                bloodGroupDropDownList.DataBind();

                religionDropDownList.DataSource     = _dropDownManager.GetAllReligion();
                religionDropDownList.DataTextField  = "ReligionName";
                religionDropDownList.DataValueField = "Id";
                religionDropDownList.DataBind();


                ListItem classItem = new ListItem("Select Class", "-1");
                classDropDownList.Items.Insert(0, classItem);
                ListItem districtItem = new ListItem("Select District", "-1");
                districtDropDownList.Items.Insert(0, districtItem);
                ListItem upazilaItem = new ListItem("Select Upazila", "-1");
                upazilaDropDownList.Items.Insert(0, upazilaItem);
                ListItem bloodItem = new ListItem("Select Blood Group", "-1");
                bloodGroupDropDownList.Items.Insert(0, bloodItem);
                ListItem religionItem = new ListItem("Select Religion", "-1");
                religionDropDownList.Items.Insert(0, religionItem);
            }
        }
        public int CheckingRequirements(Registation registation)
        {
            if (_registationGateway.IsUserIdExists(registation.UserId))
            {
                List <Registation> userInfoList = _registationGateway.GetAllInfo(registation.UserId);
                foreach (var userInfo in userInfoList)
                {
                    if (userInfo.Islocked == false)
                    {
                        var retryAttemps = userInfo.RetryAttemps;
                        if (retryAttemps != 4)
                        {
                            if (userInfo.Password != FormsAuthentication.HashPasswordForStoringInConfigFile(registation.Password, "SHA1"))
                            {
                                retryAttemps = retryAttemps + 1;
                                _registationGateway.UpdateUserTable(retryAttemps, registation.UserId);
                                return(0);
                            }
                            if (userInfo.Type == "admin")
                            {
                                _registationGateway.ResetAttempt(registation.UserId);
                                return(3);
                            }
                            if (userInfo.Type == "teacher")
                            {
                                _registationGateway.ResetAttempt(registation.UserId);
                                return(1);
                            }
                            if (userInfo.Type == "student")
                            {
                                _registationGateway.ResetAttempt(registation.UserId);
                                return(2);
                            }
                            return(3);
                        }
                        _registationGateway.LockUser(registation.UserId);
                    }
                    else
                    {
                        return(-2);
                    }
                }
            }

            return(-1);
        }
예제 #25
0
        public IActionResult Registration(RegistrationViewModel model)
        {
            if (ModelState.IsValid)
            {
                string password = model.CandidateName.Substring(0, 4).ToUpper() + model.Mobile.Substring(0, 4);
                Console.WriteLine(password);
                Registation registation = new Registation()
                {
                    CandidateName      = model.CandidateName,
                    Email              = model.Email,
                    Mobile             = model.Mobile,
                    ExaminationApplied = model.ExaminationApplied,
                    Password           = password
                };

                _repositry.Add(registation);
            }
            return(View());
        }
예제 #26
0
        public bool Login(string regstration_number, string password)
        {
            try
            {
                Registation reg = repo.Registations.FirstOrDefault(r => r.Registration_number == regstration_number);

                if (reg != null)
                {
                    if (reg.Password == password)
                    {
                        return(true);
                    }
                }
            }catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
            return(false);
        }
예제 #27
0
 public bool Add(Registation registation)
 {
     try
     {
         if (UserExistes(registation.Email, registation.Mobile))
         {
             return(false);
         }
         registation.Registration_number = (20200001 + getTotalNumberOfReg()).ToString();
         Console.WriteLine(registation.Email);
         repo.Registations.Add(registation);
         repo.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
예제 #28
0
        public IActionResult Enroll()
        {
            //CenterData centerData = new CenterData();
            //EnrollmentViewModel enrollment = new EnrollmentViewModel();
            //enrollment.ExameCenterCh1 = centerData.Center();
            //enrollment.ExameCenterCh2 = centerData.Center();
            //enrollment.ExameCenterCh3 = centerData.Center();

            if (HttpContext.Session.GetString("UserName") == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            Registation         registation = registerRepositry.GetRegistationByRegistration_num(HttpContext.Session.GetString("UserName"));
            EnrollmentViewModel enrollment  = new EnrollmentViewModel();

            enrollment.Name           = registation.CandidateName;
            enrollment.ContactNumber  = registation.Mobile;
            enrollment.Email          = registation.Email;
            enrollment.Programm       = registation.ExaminationApplied;
            enrollment.ExameCenterCh1 = cernterRepositry.GetExamCentersSeatAvaiablity();
            return(View(enrollment));
        }
예제 #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int _index = 0; bool session = false; bool cookies = false;

            string[] CookiesValue = new string[Cookies.CookiesName.Length];
            string[] SessionValue = new string[Cookies.CookiesName.Length];
            foreach (var Name in Cookies.CookiesName)
            {
                if (Session[Name] != null || Request.Cookies[Name] != null)
                {
                    if (Session[Name] != null)
                    {
                        session = true; SessionValue[_index] = Session[Name].ToString();
                    }
                    if (Request.Cookies[Name] != null)
                    {
                        cookies = true; CookiesValue[_index] = Request.Cookies[Name].Value;
                    }
                }
                else
                {
                    Response.Redirect("~/login"); break;
                }
                _index++;
            }
            if (Session_Cookies_Check(CookiesValue, SessionValue, cookies, session))
            {
                if (Cookies.EmailVerify == "True" || Cookies.EmailVerify == "true")
                {
                    Response.Redirect("~/CMS/");
                }
                else
                {
                    if (Request.QueryString[""] != null && Request.QueryString["rid"] != null)
                    {
                        var         Code  = Request.QueryString[""].ToString();
                        var         RegID = Request.QueryString["rid"].ToString();
                        Registation reg   = new Registation();
                        if (reg.EmailVerification(Code, RegID))
                        {
                            Notification notification = new Notification();
                            notification.AddNotification("Your Email is Verified.", "#", IconDataFeather.mail, Cookies.Offset, Cookies.RegID);
                            Response.Redirect("~/CMS/");
                        }
                        else
                        {
                            lblResult.Text = "Error: " + reg.Message;
                        }
                    }
                    btnResend.Visible = true;
                }
            }
            else
            {
                if (Request.QueryString[""] != null && Request.QueryString["rid"] != null)
                {
                    var         Code  = Request.QueryString[""].ToString();
                    var         RegID = Request.QueryString["rid"].ToString();
                    Registation reg   = new Registation();
                    if (reg.EmailVerification(Code, RegID))
                    {
                        Response.Redirect("~/CMS/");
                    }
                    else
                    {
                        lblResult.Text = "Error: " + reg.Message;
                    }
                }
                else
                {
                    Response.Redirect("~/login");
                }
            }
        }