示例#1
0
 private static int CompareMessagesByDate(MessageModel a, MessageModel b)
 {
     if (a.time > b.time)
         return 1;
     if (b.time > a.time)
         return -1;
     return 0;
 }
示例#2
0
        public bool GetSendMessage(string from, string to,string messag)
        {
            string message = messag;
            MessageModel m = new MessageModel();
            m.To = Convert.ToInt32(to);
            m.From = Convert.ToInt32(from);
            m.Message = message;
            m.time = DateTime.Now;
            m.type = "Message";
            repository.InsertMessage(m);
            repository.Save();

            return true;
        }
示例#3
0
        public ActionResult MakeFriends(int id)
        {
            if (!User.Identity.IsAuthenticated)
                return RedirectToAction("Index", "FoursquareLogin");

            FoursquareOAuth foursquareOAuth = new FoursquareOAuth(GetCurrentUserToken());
            foursquareOAuth.MakeFriendship(id);
            MessageModel messageModel = new MessageModel()
                {
                    From = Convert.ToInt32(User.Identity.Name),
                    Message = "Accept",
                    time = DateTime.Now,
                    To = id,
                    type = "Invite"
                };
            IMessageRepository repository = new MessageRepository(new FoursquareUserContext());
            repository.InsertMessage(messageModel);
            repository.Save();
            return RedirectToAction("Chat", "Foursquare", new { id = id });
        }
        public bool GetMakeFriends(string token, string userId, string targetId)
        {
            int uId = Convert.ToInt32(userId);
            int tId = Convert.ToInt32(targetId);
            if (AuthService.ValidateAuthData(uId, token))
            {
                FoursquareOAuth foursquareOAuth = new FoursquareOAuth(token);

                MessageModel messageModel = new MessageModel()
                {
                    From = uId,
                    Message = "Accept",
                    time = DateTime.Now,
                    To = tId,
                    type = "Invite"
                };
                IMessageRepository repository = new MessageRepository(new FoursquareUserContext());
                repository.InsertMessage(messageModel);
                repository.Save();
                return foursquareOAuth.MakeFriendship(tId);
            }
            return false;
        }
示例#5
0
 public void InsertMessage(MessageModel message)
 {
     context.Messages.Add(message);
 }