Exemplo n.º 1
0
        public async Task <IActionResult> Registered(RegisteredUserViewmodel model)
        {
            var result = await _customers.CustomerRegistered(model);

            if (result)
            {
                return(Ok("注册成功"));
            }
            else
            {
                return(BadRequest("注册失败"));
            }
        }
Exemplo n.º 2
0
        public async Task <bool> CustomerRegistered(RegisteredUserViewmodel model)
        {
            var result      = true;
            var getcustomer = await _dbContext.Customerlists.FirstOrDefaultAsync(x => x.Username == model.Username);

            if (getcustomer != null)
            {
                result = false;
            }
            else
            {
                Customer cs = new Customer();
                cs.Username = model.Username;
                cs.Password = model.Password;
                cs.Email    = model.Email;
                await AddCustomerasync(cs);

                await _dbContext.SaveChangesAsync();
            }

            return(result);
        }