コード例 #1
0
        public MethodResult <UserTdm> Login(string username, string password)
        {
            return(DbSessionManager.Execute <MethodResult <UserTdm> >((IDbSession sess) => {
                UserTdm u = userWorker.FindByUserName(sess, username);
                if (null == u || String.IsNullOrEmpty(password))
                {
                    return MethodResult <UserTdm> .Failed("用户名或密码错误!");
                }

                if (u.Kind == UserKind.Virtual)
                {
                    return MethodResult <UserTdm> .Failed("账户不存在!");
                }

                if (u.RowState != RowState.Normal ||
                    (u.Locked && u.TimeLocked > DateTime.Now))
                {
                    return MethodResult <UserTdm> .Failed("账户已经被锁定,请稍后再试!");
                }

                password = password.MD5();
                if (password == u.Password)
                {
                    userWorker.SetLoginSuccess(sess, u.Id);
                    return MethodResult <UserTdm> .Successful(u);
                }

                userWorker.SetLoginFailed(sess, u.Id, u.FailCount > WebApp.PasswordFailCount);
                return MethodResult <UserTdm> .Failed("用户名或密码错误!");
            }));
        }
コード例 #2
0
 public ActionResult GetTextBooks()
 {
     return(Json(MethodResult <List <TextbookTdm> > .Successful(textBookService.GetAll())));
 }
コード例 #3
0
 public ActionResult GetEditions()
 {
     return(Json(MethodResult <List <EditionTdm> > .Successful(editionService.GetAll())));
 }
コード例 #4
0
 public ActionResult GetPublishs()
 {
     return(Json(MethodResult <List <PublishTdm> > .Successful(publishService.GetAll())));
 }
コード例 #5
0
 public ActionResult GetSubjects()
 {
     return(Json(MethodResult <List <SubjectTdm> > .Successful(subjectService.GetAll())));
 }
コード例 #6
0
 public ActionResult GetGrades()
 {
     return(Json(MethodResult <List <GradeTdm> > .Successful(gradeService.GetAll())));
 }