public IActionResult Register(RegisterDto body)
        {
            var userList = _BaseService.GetListWriteBy <Users>(x => x.Email == body.Email);
            int count    = userList.Where(x => x.CreateTime.AddHours(2) > DateTime.Now).Count();

            if (count > 0)
            {
                return(Ok(new ApiNResponse(code: CodeAndMessage.重复邮箱在俩小时内注册, message: "Repeat email to register within two hours")));
            }
            int userinfo = userList.Where(x => x.Email == body.Email && x.CreateTime.AddHours(2) < DateTime.Now).Count();

            if (userinfo > 0)
            {
                var userlist = userList.Single(x => x.Email == body.Email);

                userlist.CreateTime = DateTime.Now;
                userlist.Count      = userlist.Count + 1;
                _BaseService.ModifyNo(userlist);
                _SendService.SendEmail(body.Email, body.Email, "123456");
            }
            else
            {
                Users users = new Users()
                {
                    Id               = SequenceID.GetSequenceID(),
                    AuthRole         = AuthRole.User,
                    CreateTime       = DateTime.Now,
                    Disable          = false,
                    Email            = body.Email,
                    LastModifiedTime = DateTime.Now,
                    LoginType        = LoginType.LimitWeb,
                    UserName         = body.Email.ToString(),
                    ComPany          = body.ComPany,
                    NickName         = body.NickName,
                    Count            = 1,
                    PassWord         = HashPass.HashString("123456", "MD5")
                };
                _BaseService.Add(users);
                _SendService.SendEmail(body.Email, users.UserName, "123456");
            }
            return(Ok(new ApiResponse()));
        }
Ejemplo n.º 2
0
 public List <Test> GetAll()
 {
     if (!TestRedis.GetAll(out List <Test> tests))
     {
         tests = _EFBaseService.GetListWriteBy <Test>(u => u.Disable == false).ToList();
         if (tests != null && tests.Count > 0)
         {
             TestRedis.SaveAll(tests);
         }
     }
     return(tests);
 }
Ejemplo n.º 3
0
        public IActionResult TestEFCoreAndRedis()
        {
            List <Test> tests = _baseService.GetListWriteBy <Test>(x => x.Disable == false);

            return(Ok(new ApiResponse(tests)));
        }