コード例 #1
0
 public object createUser(CreateUSerRequest request)
 {
     try
     {
         User user = new User();
         user.Email     = request.email;
         user.FullName  = request.fullName;
         user.Address   = request.address;
         user.Username  = request.username;
         user.Password  = Hashing.HashPassword(request.password);
         user.IsRemoved = false;
         context.User.Add(user);
         context.SaveChanges();
         User temp = context.User
                     .Where(s => s.Username == user.Username)
                     .FirstOrDefault();
         return(new
         {
             access_token = GenerateJwtToken(user.Email, user, "ssshopshoeUser123"),
             expires_in = (int)TimeSpan.FromDays(30).TotalSeconds,
             user = new
             {
                 user_id = user.UserId,
                 full_name = user.FullName,
                 email = user.Email,
                 address = user.Address
             }
         });
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
コード例 #2
0
        public IActionResult CreateUser([FromBody] CreateUSerRequest request)
        {
            //repository = new UserRepositoryImpl();
            var webOwner = repository.createUser(request);

            if (webOwner != null)
            {
                return(Ok(webOwner));
            }
            return(StatusCode(400));
        }