Example #1
0
        public Authentication Login(LoginCredentials credentials)
        {
            var result = new Authentication();

            var facebookCredentials = credentials as FacebookLoginCredentials;
            if (facebookCredentials != null)
            {
                var facebookSession = new Facebook.FacebookClient(facebookCredentials.AccessToken);

                dynamic me = facebookSession.Get("me");
                var facebookUser = new FacebookUser
                {
                    FacebookUserId = long.Parse(me["id"]),
                    UserName = me["username"]
                };

                result.UserId = _data.CheckOrInsertFacebookUser(facebookUser);
                var session = StartSession(result.UserId);
                result.Ticket = session.Key;
                result.ValidTill = session.Value;

                return result;
            }

            throw new NotImplementedException("Only facebook users are supported now");
        }
Example #2
0
 public List<Message> GetRelevantMessages(Authentication auth, int skip, int take)
 {
     using (var business = new SocialServiceBusiness())
     {
         business.Authentication.AuthenticateUser(auth);
         return business.Groups.GetRelevantMessages(auth.UserId, skip, take);
     }
 }
Example #3
0
 public List<Message> GetMessages(Authentication auth, int groupId)
 {
     using (var business = new SocialServiceBusiness())
     {
         business.Authentication.AuthenticateUser(auth);
         return business.Groups.GetMessages(auth.UserId, groupId);
     }
 }
Example #4
0
 public List<GroupExtended> GetGroupsExtended(Authentication auth)
 {
     using (var business = new SocialServiceBusiness())
     {
         business.Authentication.AuthenticateUser(auth);
         return business.Groups.GetGroupsExtended(auth.UserId);
     }
 }
Example #5
0
 public List<Group> GetGroups(Authentication auth)
 {
     using (var business = new SocialServiceBusiness())
     {
         business.Authentication.AuthenticateUser(auth);
         return business.Groups.GetGroups();
     }
 }
Example #6
0
 public Group GetGroup(Authentication auth, int groupId)
 {
     using (var business = new SocialServiceBusiness())
     {
         business.Authentication.AuthenticateUser(auth);
         return business.Groups.GetGroup(groupId);
     }
 }
Example #7
0
 public void EnrollInGroup(Authentication auth, int groupId)
 {
     using (var business = new SocialServiceBusiness())
     {
         business.Authentication.AuthenticateUser(auth);
         business.Groups.EnrollInGroup(auth.UserId, groupId);
     }
 }
Example #8
0
 public void DeleteMessage(Authentication auth, int messageId)
 {
     using (var business = new SocialServiceBusiness())
     {
         business.Authentication.AuthenticateUser(auth);
         business.Groups.DeleteMessage(auth.UserId, messageId);
     }
 }
Example #9
0
 public int AddGroup(Authentication auth, Group group)
 {
     using (var business = new SocialServiceBusiness())
     {
         business.Authentication.AuthenticateUser(auth);
         return business.Groups.AddGroup(group);
     }
 }
        public Sessions GetSession(Authentication header)
        {
            if (header == null)
                return null;

            var result = _data.Sessions.SingleOrDefault(s => s.userId == header.UserId
                && s.ticket == header.Ticket);

            if (result != null)
                if (result.validTill.ToShortDateString() != header.ValidTill.ToShortDateString())
                    result = null;

            return result;
        }
Example #11
0
 public void PostMessage(Authentication auth, Message message, int? parentId)
 {
     using(var business = new SocialServiceBusiness())
     {
         business.Authentication.AuthenticateUser(auth);
         business.Groups.PostMessage(message, parentId);
     }
 }
Example #12
0
 public Sessions GetSession(Authentication header)
 {
     throw new NotImplementedException();
 }
Example #13
0
 public void AuthenticateUser(Authentication auth)
 {
     var session = _data.GetSession(auth);
     if (session == null)
         throw new AccessViolationException("Header is not valid");
 }