コード例 #1
0
        public ActionResult Create(UsersCreateViewModel model)
        {
            string           validationCode = HashUtils.CreateReferralCode();
            var              repository     = new UserRepository();
            SendConfirmEmail emailSender    = new SendConfirmEmail();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            User user = new User();

            user.ImgURL           = model.ImgURL;
            user.Email            = model.Email;
            user.Username         = model.Username;
            user.Password         = model.Password;
            user.FirstName        = model.FirstName;
            user.LastName         = model.LastName;
            user.IsAdmin          = model.IsAdmin;
            user.IsEmailConfirmed = false;
            user.ValidationCode   = validationCode;

            repository.Insert(user);

            sendConfirmEmail.SendConfirmationEmailAsync(user);

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public async Task <ActionResult> Register(CRUDStudentViewModel model)
        {
            string         validationCode = HashUtils.CreateReferralCode();
            var            repository     = new StudentRepository();
            List <Student> students       = repository.GetAll();

            SendConfirmEmail emailSender = new SendConfirmEmail();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (students.Where(u => u.Email == model.Email).Any())
            {
                ModelState.AddModelError("error_email", "This email is already taken!");
                return(View());
                //return View("Error");
            }
            else if (students.Where(u => u.Username == model.Username).Any())
            {
                ModelState.AddModelError("error_msg", "This username is already taken!");
                return(View());
                // return View("Error");
            }
            else
            {
                Student student = new Student();
                student.ImgURL           = model.ImgURL;
                student.Username         = model.Username;
                student.Password         = model.Password;
                student.Email            = model.Email;
                student.FirstName        = model.FirstName;
                student.LastName         = model.LastName;
                student.IsAdmin          = model.IsAdmin;
                student.IsEmailConfirmed = false;
                student.ValidationCode   = validationCode;
                student.FacultyNumber    = model.FacultyNumber;
                student.Specialty        = model.Specialty;
                student.GroupId          = model.GroupId;
                student.IsTeacher        = model.IsTeacher;
                student.IsStudent        = model.IsStudent;

                repository.Insert(student);

                sendConfirmEmail.SendConfirmationEmailAsync(student);
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #3
0
        public async Task <ActionResult> Register(UserCreateViewModel model)
        {
            string      validationCode = HashUtils.CreateReferralCode();
            var         repository     = new UserRepository();
            List <User> users          = repository.GetAll();

            SendConfirmEmail emailSender = new SendConfirmEmail();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (users.Where(u => u.Email == model.Email).Any())
            {
                ModelState.AddModelError("error_email", "This email is already taken!");
                return(View());
                //return View("Error");
            }
            else if (users.Where(u => u.Username == model.Username).Any())
            {
                ModelState.AddModelError("error_msg", "This username is already taken!");
                return(View());
                // return View("Error");
            }
            else
            {
                User user = new User();
                user.ImgURL           = model.ImgURL;
                user.Username         = model.Username;
                user.Password         = model.Password;
                user.Email            = model.Email;
                user.FirstName        = model.FirstName;
                user.LastName         = model.LastName;
                user.IsAdmin          = model.IsAdmin;
                user.IsEmailConfirmed = false;
                user.ValidationCode   = validationCode;
                user.IsStudent        = model.IsStudent;
                user.IsTeacher        = model.IsTeacher;

                repository.Insert(user);

                sendConfirmEmail.SendConfirmationEmailAsync(user);
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #4
0
        public ActionResult Create(CRUDTeacherViewModel model)
        {
            string           validationCode = HashUtils.CreateReferralCode();
            var              repository     = new TeacherRepository();
            SendConfirmEmail emailSender    = new SendConfirmEmail();

            List <Teacher> teachers = repository.GetAll();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (teachers.Where(u => u.Email == model.Email).Any())
            {
                ModelState.AddModelError("error_email", "This email is already taken!");
                return(View());
                //return View("Error");
            }
            else if (teachers.Where(u => u.Username == model.Username).Any())
            {
                ModelState.AddModelError("error_msg", "This username is already taken!");
                return(View());
                // return View("Error");
            }
            else
            {
                Teacher teacher = new Teacher();
                // user.Id = model.Id;
                teacher.ImgURL           = model.ImgURL;
                teacher.Username         = model.Username;
                teacher.Password         = model.Password;
                teacher.Email            = model.Email;
                teacher.FirstName        = model.FirstName;
                teacher.LastName         = model.LastName;
                teacher.IsAdmin          = model.IsAdmin;
                teacher.IsEmailConfirmed = false;
                teacher.ValidationCode   = validationCode;
                teacher.Subject          = model.Subject;
                teacher.IsTeacher        = model.IsTeacher;

                repository.Insert(teacher);

                sendConfirmEmail.SendConfirmationEmailAsync(teacher);
            }
            return(RedirectToAction("Index"));
        }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["thisCart"] == null)
        {
            Response.Write("<script>alert('There was an error loading your shopping cart!')</script>");
            Response.Redirect("/Home.aspx");
        }
        else
        {
            thisCart = (ShoppingCart)Session["thisCart"];
        }
        if (thisCart.Items.Count == 0)
        {
            Response.Write("<script>alert('Your shopping cart is empty!')</script>");
            Response.Redirect("/Home.aspx");
        }
        if (Session["shippingInfo"] == null)
        {
            Response.Redirect("/CheckoutStopOne.aspx");
        }
        else
        {
            shippingInfo = (string[])Session["shippingInfo"];
            PopulateShippingInfo();
            SendConfirmEmail.SendEmail();
        }

        if (!IsPostBack)
        {
            lblTax.Text              = shippingInfo[6];
            lblTotal.Text            = shippingInfo[7];
            dlCartSummary.DataSource = thisCart.Items;
            dlCartSummary.DataBind();
            lblSubtotal.Text = string.Format("Item's Subtotal: {0,19:C}", thisCart.GrandTotal);

            BackOrderMessage();
            UpdateStock();
            SaveOrder();

            Session["thisCart"] = null;
        }
    }