public ActionResult SignUp(ClassSignUp SignUp, ClassSignIn SignIn)
        {
            ComputerShopEntities data = new ComputerShopEntities();


            int a = data.Users.Where(x => x.UserName.Equals(SignUp.userName)).Count();

            if (a == 0)
            {
                User user = new User();

                user.UserName = SignUp.userName;
                user.PassWord = SignUp.passWord;
                user.Address  = SignUp.address;
                user.Phone    = SignUp.Phone;
                user.role     = "Member";
                if (SignUp.rePassWord != SignUp.passWord)
                {
                    ViewBag.a = "Mật Khẩu và Nhập Lại Mật Khẩu Không Đúng";
                    return(View());
                }
                else
                {
                    ViewBag.a = "Đăng kí thành công";
                    data.Users.Add(user);
                    data.SaveChanges();
                    return(View());
                }
            }
            else
            {
                ViewBag.b = "Tên đăng nhập đã tồn tại";
                return(View());
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <QrToTeacher> > Get(string ClassId)
        {
            int SignNum;

            //计算签到次数
            try
            {
                var result = db.OpeningClass.Where(s => s.ClassId == ClassId).FirstOrDefault();
                SignNum = result.Times - 1;
            }
            catch
            {
                return(BadRequest());
            }
            //若上一次签到未关闭,则将其设置为过期
            try
            {
                var result = db.ClassSignIn.Where(s => s.ClassId == ClassId).OrderBy(s => s.SignInDate).LastOrDefault();

                if (result != null && result.IsOverDue == 0)
                {
                    result.IsOverDue = 1;
                }
            }
            catch
            {
                return(BadRequest());
            }

            string FilePathstr = Environment.CurrentDirectory + @"\wwwroot\img\code" + ClassId + @".jpg";
            string CodeStr     = GetRandomString(40);

            try
            {
                code(CodeStr, 10, 40, 30, 1, false).Save(FilePathstr, ImageFormat.Jpeg);
                var si = new ClassSignIn(CodeStr, ClassId, DateTime.Now, SignNum);
                await db.ClassSignIn.AddAsync(si);

                await db.SaveChangesAsync();
            }
            catch
            {
                return(BadRequest("出问题啦~"));
            }

            return(new QrToTeacher(@"img\code" + ClassId + @".jpg", CodeStr));
        }
        public ActionResult SignIn(ClassSignIn SignIn)
        {
            ComputerShopEntities data = new ComputerShopEntities();
            var b = data.Users.Where(x => x.UserName.Equals(SignIn.UserName) && x.PassWord.Equals(SignIn.PassWord)).FirstOrDefault();

            if (b != null)
            {
                if (b.role == "admin" || b.role == "admin")
                {
                    Session["SignIn"] = b;
                    return(RedirectToAction("Index", "MainProcess"));
                }
            }
            else
            {
                ViewBag.a = "sai ten tai khoan mat khau";
            }
            return(View());
        }