Exemplo n.º 1
0
 public void AddUser(Person model, out string _ValidationMessage)
 {
     _ValidationMessage = string.Empty;
     try
     {
         using (DOTNETEntities _TwitterEntity = new DOTNETEntities())
         {
             Person isExist = (from p in _TwitterEntity.People
                               where p.username == model.username
                               select p).FirstOrDefault();
             if (isExist == null)
             {
                 _TwitterEntity.People.Add(model);
                 _TwitterEntity.SaveChanges();
                 _ValidationMessage = "User " + model.username + " Successfully Created!.";
             }
             else
             {
                 _ValidationMessage = "This user " + model.username + " Already Exists!.";
             }
         }
     }
     catch (Exception ex)
     {
         string error = ex.Message;
         throw;
     }
 }
Exemplo n.º 2
0
        public Person AddFollowerByUser(int userID, string userName, out string message)
        {
            Person _Person = new Person();

            message = string.Empty;
            using (var db = new DOTNETEntities())
            {
                _Person = (from p in db.People
                           where p.username == userName
                           select p).FirstOrDefault();

                if (_Person != null && _Person.user_id != 0)
                {
                    Follower _addUser = new Follower()
                    {
                        user_id = userID, follower_id = _Person.user_id
                    };
                    if (!db.Followers.Where(s => s.user_id == _addUser.user_id && s.follower_id == _addUser.follower_id).Any())
                    {
                        db.Followers.Add(_addUser);
                        db.SaveChanges();
                        message = "Follower is added";
                    }
                    else
                    {
                        message = "Follower is already in your list!.";
                    }
                }
            }

            return(_Person);
        }
Exemplo n.º 3
0
        public void SaveTweet(Tweet _tweet, int user_id, out string _ValidationMessage)
        {
            _ValidationMessage = string.Empty;


            using (DOTNETEntities _TwitterEntity = new DOTNETEntities())
            {
                _TwitterEntity.Tweets.Add(_tweet);
                _TwitterEntity.SaveChanges();
                _ValidationMessage = "Tweet Successfully Posted!.";
            }
        }