예제 #1
0
        public string RegisterProfile(string accessToken, Users user)
        {
            string authDomain = authConfig.Domain;
            AuthenticationApiClient authClient = new AuthenticationApiClient(authDomain);

            UserInfo userInfo = authClient.GetUserInfoAsync(accessToken).Result;

            user.IsSuspended = false;
            user.Usertag     = userInfo.NickName;

            Users dbuser = db.Users.FirstOrDefault(e => e.Usertag == user.Usertag);

            if (dbuser == null)
            {
                db.Attach <Users>(user);
                db.Add <Users>(new Users()
                {
                    FirstName      = user.FirstName,
                    LastName       = user.LastName,
                    Usertag        = user.Usertag,
                    ProfilePicture = user.ProfilePicture,
                    IsSuspended    = false
                });
                db.SaveChanges();
            }
            else
            {
                return(ToJson(new UserComponent(dbuser)));
            }

            ConfigureManagementApi(user, userInfo);
            return(ToJson(new UserComponent(dbuser)));
        }
 public void SaveChanges()
 {
     db.SaveChanges();
 }
예제 #3
0
 //Adds new post to Posts Table
 public Posts AddPost(Posts post)
 {
     db.Posts.Add(post);
     db.SaveChanges();
     return(post);
 }
예제 #4
0
 //Adds comment to Comments Table
 public Comments AddComment(Comments comment)
 {
     db.Comments.Add(comment);
     db.SaveChanges();
     return(comment);
 }
 //Adds a location to Locations Table
 public Locations AddLocation(Locations location)
 {
     db.Locations.Add(location);
     db.SaveChanges();
     return(location);
 }