Exemplo n.º 1
0
        public ActionResult SignIn(string email, string password)
        {
            JsonResultItem result = new Models.JsonResultItem();

            if (!string.IsNullOrWhiteSpace(email) && !string.IsNullOrWhiteSpace(password))
            {
                using (AandQContext db = new AandQContext())
                {
                    var entity = db.Accounts.FirstOrDefault(d => d.Email == email && d.Password == password);
                    if (entity == null)
                    {
                        result.Status = 2;
                        result.Msg    = "用户名或密码错误!";
                    }
                    else
                    {
                        this.HttpContext.Session[UserConfig.SESSION_NAME] = new UserInfo {
                            UserName = entity.Email, Email = entity.Email
                        };
                        result.Status = 0;
                        result.Msg    = "登录成功!";
                    }
                }
            }
            else
            {
                result.Status = 1;
                result.Msg    = "用户名或密码不能为空!";
            }
            return(Json(result));
        }
Exemplo n.º 2
0
        public ActionResult ExistEmail(string email)
        {
            JsonResultItem result = new Models.JsonResultItem();

            if (!string.IsNullOrWhiteSpace(email))
            {
                using (AandQContext db = new AandQContext())
                {
                    var entity = db.Accounts.FirstOrDefault(d => d.Email == email);
                    if (entity == null)
                    {
                        result.Status = 0;
                    }
                    else
                    {
                        result.Status = 1;
                    }
                }
            }
            else
            {
                result.Status = 2;
            }
            return(Json(result));
        }
        //
        // GET: /Question/

        public ActionResult List(long last, int count)
        {
            IEnumerable <Question> list;

            using (AandQContext db = new AandQContext())
            {
                list = db.Questions.Where(d => d.AccountID > last).Take(count).ToList();
            }
            return(View(list));
        }
Exemplo n.º 4
0
        public ActionResult AddAccount(string email, string password, string name)
        {
            JsonResultItem result = new Models.JsonResultItem();

            //ModelState.IsValid
            if (email.IsEmail())
            {
                if (string.IsNullOrWhiteSpace(password) == false && password.Length >= 6)
                {
                    using (AandQContext db = new AandQContext())
                    {
                        var entity = db.Accounts.FirstOrDefault(d => d.Email == email);
                        if (entity == null)
                        {
                            entity          = new Account();
                            entity.Email    = email;
                            entity.Password = password;
                            entity.UserName = name.Trim();
                            db.Accounts.Add(entity);
                            db.SaveChanges();
                            result.Status = 0;
                            result.Msg    = "注册成功!";
                        }
                        else
                        {
                            result.Status = 1;
                            result.Msg    = "该邮箱已经被注册了!";
                        }
                    }
                }
                else
                {
                    result.Status = 3;
                    result.Msg    = "密码长度不能小于6位!";
                }
            }
            else
            {
                result.Status = 2;
                result.Msg    = "该邮箱格式错误!";
            }

            return(Json(result));
        }
 public ActionResult Add(string question)
 {
     if (!string.IsNullOrWhiteSpace(question))
     {
         using (AandQContext db = new AandQContext())
         {
             var entity = db.Questions.FirstOrDefault(d => d.Title == question);
             if (entity == null)
             {
                 entity           = new Question();
                 entity.Title     = question.Trim();
                 entity.AccountID = this.UserInfo.AccountID;
             }
             return(Redirect("/Question/Mylist"));
         }
     }
     else
     {
         return(Content("问题不能为空!"));
     }
 }