コード例 #1
0
ファイル: SignupController.cs プロジェクト: TinThomas/Prj4
        public async Task <IActionResult> Signup([FromBody] Login val)
        {
            UserDataContext userDatadb = new UserDataContext();
            UserNContext    userNamedb = new UserNContext();
            PassContext     passworddb = new PassContext();

            //At this stage we have no userData besides the ID
            //Creating this object automatically generates an ID
            UserDataDB userData = new UserDataDB();

            //Create new username and password database entries with the same key
            UserNDB userName = new UserNDB(userData.UserId);

            userName.Email    = val.email;
            userName.UserName = val.username;
            PassDB password = new PassDB(userData.UserId);

            password.Password = val.password;

            userDatadb.Add(userData);
            userNamedb.Add(userName);
            passworddb.Add(password);

            //update the databases
            try
            {
                userDatadb.SaveChanges();
                userNamedb.SaveChanges();
                passworddb.SaveChanges();
            }
            catch (DbUpdateException)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            return(Ok(200));

            //string newUser = JsonSerializer.Serialize(val);
            //bool complete = await be.incomming(1, 3, newUser);
            //bool complete = true;
            //if (complete)
            //{
            //    return Ok(200);
            //}
            //return BadRequest(400);
        }
コード例 #2
0
ファイル: UserName.cs プロジェクト: TinThomas/Prj4
        public int FindUserByEmail(UserNContext context, string email)
        {
            var user = context.UserNs.Single(p => p.Email.Equals(email));

            return(user.UserNId);
        }
コード例 #3
0
ファイル: UserName.cs プロジェクト: TinThomas/Prj4
        public int FindUserByName(UserNContext context, string userName)
        {
            var user = context.UserNs.Single(p => p.UserName.Equals(userName));

            return(user.UserNId);
        }