Esempio n. 1
0
        protected void LinkButtonUpdate_Command(object sender, CommandEventArgs e)
        {
            try
            {
                int channelId = Convert.ToInt32(e.CommandArgument);

                TwitterEntities context = new TwitterEntities();

                var channel = context.Channels.FirstOrDefault(x => x.ChannelId == channelId);
                var button  = sender as LinkButton;

                var tr = button.Parent.Parent;

                var textBox = tr.FindControl("TextBoxEditChannel") as TextBox;

                string newChannelName = textBox.Text;
                Verificator.ValidateChannel(newChannelName);
                channel.Name = newChannelName;
                context.SaveChanges();
                ErrorSuccessNotifier.AddInfoMessage("Channel name updated successfully.");
            }
            catch (Exception ex)
            {
                ErrorSuccessNotifier.AddErrorMessage(ex);
            }
        }
Esempio n. 2
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridViewMyChannels_DeleteItem(int ChannelId)
        {
            try
            {
                int channelId = ChannelId;

                TwitterEntities context = new TwitterEntities();

                var channel = context.Channels.Include("Messages").FirstOrDefault(x => x.ChannelId == channelId);

                string currentUsername = User.Identity.Name;
                if (channel.AspNetUser.UserName != currentUsername)
                {
                    throw new Exception("Different owner of the channel.");
                }

                var messages = channel.Messages;

                context.Messages.RemoveRange(messages);
                context.Channels.Remove(channel);
                context.SaveChanges();
                ErrorSuccessNotifier.AddInfoMessage("Channel successfully removed.");
            }
            catch (Exception ex)
            {
                ErrorSuccessNotifier.AddErrorMessage(ex);
            }
            //Response.Redirect(Request.RawUrl);
        }
Esempio n. 3
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void ListViewAllUsers_UpdateItem(string Id)
        {
            TwitterEntities context = new TwitterEntities();

            Twitter.Models.AspNetUser item = null;
            // Load the item here, e.g. item = MyDataLayer.Find(id);
            item = context.AspNetUsers.Find(Id);
            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", Id));
                return;
            }
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                try
                {
                    context.SaveChanges();
                    ErrorSuccessNotifier.AddInfoMessage("User has been successfully edited");
                }
                catch (Exception ex)
                {
                    ErrorSuccessNotifier.AddErrorMessage(ex.Message);
                }

                // Save changes here, e.g. MyDataLayer.SaveChanges();
            }
        }
Esempio n. 4
0
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            TwitterEntities context  = new TwitterEntities();
            string          userName = UserName.Text;
            var             manager  = new AuthenticationIdentityManager(new IdentityStore());
            User            u        = new User(userName)
            {
                UserName = userName
            };
            IdentityResult result = manager.Users.CreateLocalUser(u, Password.Text);


            var role = context.AspNetRoles.FirstOrDefault(x => x.Name == "User");


            if (result.Success)
            {
                string userId = u.Id;

                AspNetUser currentUser = context.AspNetUsers.FirstOrDefault(x => x.Id == userId);
                currentUser.AspNetRoles.Add(role);
                context.SaveChanges();

                manager.Authentication.SignIn(Context.GetOwinContext().Authentication, u.Id, isPersistent: false);
                OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                ErrorMessage.Text = result.Errors.FirstOrDefault();
            }
        }
Esempio n. 5
0
        protected void ButtonCreateMessage_Click(object sender, EventArgs e)
        {
            try
            {
                int channelId = Convert.ToInt32(this.DropDownListChannels.SelectedValue);

                TwitterEntities context = new TwitterEntities();
                Message         msg     = new Message();
                Channel         channel = context.Channels.Find(channelId);

                msg.Channel = channel;
                string msgText = MessageContent.Text;

                Verificator.ValidateMessage(msgText);

                msg.MessageContent = msgText;
                var currentUserName = this.User.Identity.Name;
                var author          = context.AspNetUsers.FirstOrDefault(x => x.UserName == currentUserName);

                msg.AspNetUser = author;
                msg.Date       = DateTime.Now;
                context.Messages.Add(msg);
                context.SaveChanges();
                ErrorSuccessNotifier.AddSuccessMessage("Message created successfully.");
                ErrorSuccessNotifier.ShowAfterRedirect = true;
                Response.Redirect("ChannelMessages.aspx?channelId=" + channelId, false);
            }
            catch (Exception ex)
            {
                ErrorSuccessNotifier.AddErrorMessage(ex);
            }
        }
Esempio n. 6
0
        protected void ButtonCreateChannel_Click(object sender, EventArgs e)
        {
            try
            {
                TwitterEntities context         = new TwitterEntities();
                Channel         channel         = new Channel();
                var             currentUserName = this.User.Identity.Name;
                var             author          = context.AspNetUsers.FirstOrDefault(x => x.UserName == currentUserName);

                Verificator.ValidateChannel(ChannelName.Text);

                channel.AspNetUser = author;
                channel.Name       = ChannelName.Text;
                context.Channels.Add(channel);
                context.SaveChanges();

                ErrorSuccessNotifier.AddSuccessMessage("Channel created successfully.");
                ErrorSuccessNotifier.ShowAfterRedirect = true;

                Response.Redirect("../Messages/ChannelMessages.aspx?channelId=" + channel.ChannelId, false);
            }
            catch (Exception ex)
            {
                ErrorSuccessNotifier.AddErrorMessage(ex);
            }
        }
Esempio n. 7
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridViewMyChannels_UpdateItem(int ChannelId)
        {
            TwitterEntities context = new TwitterEntities();

            Twitter.Models.Channel item = null;
            // Load the item here, e.g. item = MyDataLayer.Find(id);
            item = context.Channels.Find(ChannelId);
            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", ChannelId));
                return;
            }
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                try
                {
                    Verificator.ValidateChannel(item.Name);
                    context.SaveChanges();
                    ErrorSuccessNotifier.AddInfoMessage("Channel updated successfully");
                }
                catch (Exception ex)
                {
                    ErrorSuccessNotifier.AddErrorMessage(ex.Message);
                }
                // Save changes here, e.g. MyDataLayer.SaveChanges();
            }
        }
        protected void UploadPicture_ServerClick(object sender, EventArgs e)
        {
            var username = User.Identity.Name;

            if ((avatarPicture.PostedFile != null) && (avatarPicture.PostedFile.ContentLength > 0))
            {
                TwitterEntities context      = new TwitterEntities();
                var             user         = context.AspNetUsers.FirstOrDefault(x => x.UserName == username);
                var             userId       = user.Id;
                string          fn           = userId + System.IO.Path.GetExtension(avatarPicture.PostedFile.FileName);
                string          SaveLocation = Server.MapPath("Data") + "\\" + fn;

                try
                {
                    avatarPicture.PostedFile.SaveAs(SaveLocation);
                    Response.Write("The file has been uploaded.");
                    user.ProfilePicture = fn;
                    context.SaveChanges();
                    Response.Write(fn);
                    Response.Redirect("Manage");
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                    //Note: Exception.Message returns a detailed message that describes the current exception.
                    //For security reasons, we do not recommend that you return Exception.Message to end users in
                    //production environments. It would be better to put a generic error message.
                }
            }
            else
            {
                Response.Write("Please select a file to upload.");
            }
        }
Esempio n. 9
0
 public void Create(Hashtag hashtag)
 {
     using (var context = new TwitterEntities())
     {
         context.Hashtags.Add(hashtag);
         context.SaveChanges();
     }
 }
Esempio n. 10
0
 //dohvaća komentare za t
 public void Create(Comment comment)
 {
     using (var context = new TwitterEntities())
     {
         context.Comments.Add(comment);
         context.SaveChanges();
     }
 }
Esempio n. 11
0
 public void Create(User user)
 {
     using (var context = new TwitterEntities())
     {
         context.Users.Add(user);
         context.SaveChanges();
     }
 }
 public void Create(Location location)
 {
     using (var context = new TwitterEntities())
     {
         context.Locations.Add(location);
         context.SaveChanges();
     }
 }
 public void Create(Tweet tweet)
 {
     using (var context = new TwitterEntities())
     {
         context.Tweets.Add(tweet);
         context.SaveChanges();
     }
 }
Esempio n. 14
0
        public string SignUp(Person model)
        {
            Person oldUser = new Person();

            oldUser = context.People.FirstOrDefault(p => p.UserId == model.UserId || p.Email == model.Email);
            if (oldUser == null)
            {
                model.Active = true;
                model.Joined = DateTime.Now;
                context.People.Add(model);
                context.SaveChanges();
                return("Success");
            }
            else
            {
                return("Duplicate User");
            }
        }
Esempio n. 15
0
        protected void HyperLinkAddMessage_Click(object sender, EventArgs e)
        {
            try
            {
                int channelId = Convert.ToInt32(Request.Params["channelId"]);

                TwitterEntities context = new TwitterEntities();

                string currentUserName = User.Identity.Name;

                LinkButton button = sender as LinkButton;

                var tr = button.Parent.Parent;

                var trControls = tr.Controls;

                string messageContent = null;

                foreach (Control tdControl in trControls)
                {
                    foreach (Control control in tdControl.Controls)
                    {
                        if (control.ID == "MessageContent")
                        {
                            messageContent = (control as TextBox).Text;
                        }
                    }
                }

                Verificator.ValidateMessage(messageContent);

                string userId = context.AspNetUsers.FirstOrDefault(x => x.UserName == currentUserName).Id;

                Message message = new Message()
                {
                    ChannelId      = channelId,
                    Date           = DateTime.Now,
                    MessageContent = messageContent,
                    UserId         = userId
                };

                context.Messages.Add(message);
                context.SaveChanges();
                this.GridViewMessages.DataBind();
                this.InfoHolder.Visible = false;
                //ErrorSuccessNotifier.ShowAfterRedirect = false;
                //ErrorSuccessNotifier.AddSuccessMessage("Message created successfully.");
            }
            catch (Exception ex)
            {
                this.InfoHolder.InnerText = ex.Message;
                this.InfoHolder.Attributes.Add("class", "alert alert-error");
                this.InfoHolder.Visible = true;
                //ErrorSuccessNotifier.ShowAfterRedirect = false;
                //ErrorSuccessNotifier.AddErrorMessage(ex);
            }
        }
Esempio n. 16
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridViewMessages_DeleteItem(int MessageId)
        {
            int messageId = MessageId;

            TwitterEntities context = new TwitterEntities();

            var message = context.Messages.Find(messageId);

            context.Messages.Remove(message);
            context.SaveChanges();
        }
Esempio n. 17
0
        public bool Delete(int id)
        {
            bool result = false;
            using (context = new TwitterEntities())
            {
                var tweet = GetById(id);
                context.Tweets.Remove(tweet);
                result = context.SaveChanges() > 0;
                Logger.Log.Debug("user ID:" + tweet.User_Id + " " + userDao.GetById(tweet.User_Id).Email + " deleted a tweet ID:" + tweet.Id);
            }

            return result;
        }
Esempio n. 18
0
        public bool Delete(User user)
        {
            bool result = false;

            using (var context = new TwitterEntities())
            {
                context.Users.Attach(user);
                context.Entry(user).State = EntityState.Deleted;
                result = context.SaveChanges() > 0;
                Logger.Log.Debug("user ID:" + user.Id + " " + user.Email + " was deleted successfully");
            }
            return result;
        }
Esempio n. 19
0
        public bool AddNewTwit(int id, string content)
        {
            Twit t = new Twit();

            t.UserId      = id;
            t.TwitContent = content;
            t.Date        = DateTime.Now;
            db.Twits.Add(t);
            db.SaveChanges();
            return(true);
        }
Esempio n. 20
0
 public bool Delete(Tweet tweet)
 {
     bool result = false;
     using (context = new TwitterEntities())
     {
         tweet.User = userDao.GetById(tweet.User_Id);
         context.Tweets.Attach(tweet);
         context.Tweets.Remove(tweet);
         //context.Entry(tweet).State = EntityState.Deleted;
         result = context.SaveChanges() > 0;
         Logger.Log.Debug("user ID:" + tweet.User_Id + " " + userDao.GetById(tweet.User_Id).Email + " deleted a tweet ID:" + tweet.Id);
     }
     return result;
 }
Esempio n. 21
0
        public bool Delete(int id)
        {
            bool result = false;
            using (var context = new TwitterEntities())
            {
                var follow = GetById(id);

                context.Follows.Attach(follow);
                context.Follows.Remove(follow);
                result = context.SaveChanges() > 0;
                Logger.Log.Debug("A new follow pair deleted with publisherId " + follow.Publisher_Id + " and subscriberId " + follow.Subscriber_Id);
            }
            return result;
        }
Esempio n. 22
0
        protected void LinkButtonDeleteChannel_Command(object sender, CommandEventArgs e)
        {
            int channelId = Convert.ToInt32(e.CommandArgument);

            TwitterEntities context = new TwitterEntities();

            var channel = context.Channels.Include("Messages").FirstOrDefault(x => x.ChannelId == channelId);

            var messages = channel.Messages;

            context.Messages.RemoveRange(messages);
            context.Channels.Remove(channel);
            context.SaveChanges();
            Response.Redirect(Request.RawUrl);
        }
Esempio n. 23
0
        public bool Update(User user)
        {
            var pass = GetById(user.Id).Passwrd;
            bool result = false;
            user.Passwrd = pass;

            using (var context = new TwitterEntities())
            {
                context.Users.Attach(user);
                context.Entry(user).State = EntityState.Modified;
                result = context.SaveChanges() > 0;
                Logger.Log.Debug("User ID:" + user.Id + " " + user.Email + " was updated successfully");
            }
            return result;
        }
Esempio n. 24
0
        public bool Add(User user)
        {
            if (user == null) return false;

            bool result = false;

            using (var context = new TwitterEntities())
            {
                context.Users.Attach(user);
                context.Entry(user).State = EntityState.Added;
                result = context.SaveChanges() > 0;
                Logger.Log.Debug("new user ID:" + user.Id + " " + user.Email + " was added successfully");
            }
            return result;
        }
        public void Delete(Tweet tweet, User user)
        {
            using (var context = new TwitterEntities())
            {
                var exisitngFavouriteTweet = (from favs in context.FavouriteTweets
                                             where (favs.Tweet1 == tweet && favs.User == user)
                                             select favs).SingleOrDefault();

                if (exisitngFavouriteTweet != null )
                {
                    context.FavouriteTweets.Remove(exisitngFavouriteTweet);
                    context.SaveChanges();
                }
            }
        }
        protected void FollowButton_Click(object sender, EventArgs e)
        {
            string username = Request.Params["username"];

            string currentUserName = User.Identity.Name;

            TwitterEntities context = new TwitterEntities();

            AspNetUser currentUser   = context.AspNetUsers.Include("AspNetUsers").FirstOrDefault(x => x.UserName == currentUserName);
            var        followingUser = context.AspNetUsers.FirstOrDefault(x => x.UserName == username);

            currentUser.AspNetUsers1.Add(followingUser);
            context.SaveChanges();
            Response.Redirect(Request.RawUrl);
        }
        public void Update(int id)
        {
            using (var context = new TwitterEntities())
            {
                var tweet = context.Tweets.SingleOrDefault(t => t.ID == id);
                if(tweet != null)
                {
                    context.FavouriteTweets.RemoveRange(tweet.FavouriteTweets);
                    context.Comments.RemoveRange(tweet.Comments);
                    context.Tweets.Remove(tweet);

                    context.SaveChanges();
                }
            }
        }
Esempio n. 28
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridViewMyMessages_DeleteItem(int MessageId)
        {
            try
            {
                TwitterEntities context = new TwitterEntities();

                var message = context.Messages.FirstOrDefault(x => x.MessageId == MessageId);
                context.Messages.Remove(message);
                context.SaveChanges();
                ErrorSuccessNotifier.AddInfoMessage("Message has been deleted successfully");
            }
            catch (Exception ex)
            {
                ErrorSuccessNotifier.AddErrorMessage(ex);
            }
        }
        public void Create(Tweet tweet, User user)
        {
            using (var context = new TwitterEntities())
            {
                var existingTweet   = context.Tweets.SingleOrDefault(x => x.ID == tweet.ID);
                var existingUser    = context.Users.SingleOrDefault(x => x.Id == user.Id);

                if(existingTweet != null && existingUser != null)
                {
                    var favourite = new FavouriteTweet { Tweet1 = existingTweet, User = existingUser };
                    context.FavouriteTweets.Add(favourite);

                    context.SaveChanges();
                }
            }
        }
Esempio n. 30
0
        public bool Add(Tweet tweet)
        {
            bool result = false;

            using (context = new TwitterEntities())
            {
                tweet.User = userDao.GetById(tweet.User_Id);
                context.Tweets.Attach(tweet);
                context.Tweets.Add(tweet);

                result = context.SaveChanges() > 0;
                Logger.Log.Debug("user ID:" + tweet.User_Id + " " + userDao.GetById(tweet.User_Id).Email + " added a new tweet ID:" + tweet.Id);
            }

            return result;
        }
Esempio n. 31
0
        protected void DemoteAdmin_Command(object sender, CommandEventArgs e)
        {
            TwitterEntities context = new TwitterEntities();
            string          id      = e.CommandArgument.ToString();
            var             user    = context.AspNetUsers.Find(id);

            this.messageDiv.Visible = true;

            var adminRole = context.AspNetRoles.FirstOrDefault(r => r.Name == "Admin");

            user.AspNetRoles.Remove(adminRole);
            context.SaveChanges();
            this.ListViewAdmins.DataBind();
            this.ListViewRegularUsers.DataBind();
            this.messageText.InnerText          = "Admin successfully demoted!";
            this.messageDiv.Attributes["class"] = "alert alert-success";
        }
Esempio n. 32
0
        public void Update(User user)
        {
            using (var context = new TwitterEntities())
            {
                var existingUser = context.Users.SingleOrDefault(x => x.Id == user.Id);

                if(existingUser != null)
                {
                    existingUser.Nickname = user.Nickname;
                    existingUser.Location1 = user.Location1;
                    existingUser.Picture_URL = user.Picture_URL;
                    existingUser.FollowedBy = user.FollowedBy;
                    existingUser.Following = user.Following;

                    context.SaveChanges();
                }
            }
        }
Esempio n. 33
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridViewMyChannels_DeleteItem(int ChannelId)
        {
            int channelId = ChannelId;

            TwitterEntities context = new TwitterEntities();

            var channel = context.Channels.Include("Messages").FirstOrDefault(x => x.ChannelId == channelId);

            string currentUsername = User.Identity.Name;


            var messages = channel.Messages;

            context.Messages.RemoveRange(messages);
            context.Channels.Remove(channel);
            context.SaveChanges();
            //Response.Redirect(Request.RawUrl);
        }
Esempio n. 34
0
        protected void LinkButtonUpdate_Command(object sender, CommandEventArgs e)
        {
            int channelId = Convert.ToInt32(e.CommandArgument);

            TwitterEntities context = new TwitterEntities();

            var channel = context.Channels.FirstOrDefault(x => x.ChannelId == channelId);
            var button  = sender as LinkButton;

            var tr = button.Parent.Parent;

            var textBox = tr.FindControl("TextBoxEditChannel") as TextBox;

            string newChannelName = textBox.Text;

            channel.Name = newChannelName;
            context.SaveChanges();
        }
Esempio n. 35
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridViewMessages_UpdateItem(int MessageId)
        {
            TwitterEntities context = new TwitterEntities();

            Twitter.Models.Message item = null;
            // Load the item here, e.g. item = MyDataLayer.Find(id);
            item = context.Messages.Find(MessageId);
            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", MessageId));
                return;
            }
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                context.SaveChanges();
                // Save changes here, e.g. MyDataLayer.SaveChanges();
            }
        }
Esempio n. 36
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void ListViewAllUsers_DeleteItem(string Id)
        {
            string userId = Id;

            TwitterEntities context = new TwitterEntities();

            var user = context.AspNetUsers.Find(userId);

            context.Messages.RemoveRange(user.Messages);
            var channels = user.Channels;

            foreach (var channel in channels)
            {
                context.Messages.RemoveRange(channel.Messages);
            }
            context.Channels.RemoveRange(channels);
            context.AspNetUserLogins.RemoveRange(user.AspNetUserLogins);
            context.AspNetUserManagements.Remove(user.AspNetUserManagement);
            context.AspNetUsers.Remove(user);
            context.SaveChanges();
        }
Esempio n. 37
0
        public bool Add(int publisherId, int subscriberId)
        {
            bool result = false;

            var follow = new Follow
            {
                Publisher_Id = publisherId,
                Subscriber_Id = subscriberId,
                User = user.GetById(publisherId),
                User1 = user.GetById(subscriberId)
            };

            using (var context = new TwitterEntities())
            {
                context.Follows.Attach(follow);
                context.Follows.Add(follow);

                result = context.SaveChanges() > 0;
                Logger.Log.Debug("A new follow pair created with publisherId " + follow.Publisher_Id + " and subscriberId " + follow.Subscriber_Id);
            }
            return result;
        }
Esempio n. 38
0
        protected void HyperLinkAddMessage_Click(object sender, EventArgs e)
        {
            int channelId = Convert.ToInt32(Request.Params["channelId"]);

            TwitterEntities context = new TwitterEntities();

            string currentUserName = User.Identity.Name;

            string userId = context.AspNetUsers.FirstOrDefault(x => x.UserName == currentUserName).Id;

            Message message = new Message()
            {
                ChannelId      = channelId,
                Date           = DateTime.Now,
                MessageContent = this.MessageContent.Text,
                UserId         = userId
            };

            context.Messages.Add(message);
            context.SaveChanges();
            Response.Redirect(Request.RawUrl);
        }
Esempio n. 39
0
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridViewMyMessages_UpdateItem(int MessageId)
        {
            TwitterEntities context = new TwitterEntities();

            Twitter.Models.Message item = null;
            // Load the item here, e.g. item = MyDataLayer.Find(id);

            item = context.Messages.FirstOrDefault(x => x.MessageId == MessageId);
            if (item == null)
            {
                // The item wasn't found
                ModelState.AddModelError("", String.Format("Item with id {0} was not found", MessageId));
                return;
            }
            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                // Save changes here, e.g. MyDataLayer.SaveChanges();
                try
                {
                    Verificator.ValidateMessage(item.MessageContent);
                    context.SaveChanges();
                    ErrorSuccessNotifier.AddInfoMessage("Message has been edited successfully");
                }
                catch (Exception ex)
                {
                    if (ex.Message != null)
                    {
                        ErrorSuccessNotifier.AddErrorMessage(ex.Message);
                    }
                    else
                    {
                        ErrorSuccessNotifier.AddErrorMessage(ex);
                    }
                }
            }
        }
Esempio n. 40
0
        protected void LinkButtonDeleteChannel_Command(object sender, CommandEventArgs e)
        {
            try
            {
                int channelId = Convert.ToInt32(e.CommandArgument);

                TwitterEntities context = new TwitterEntities();

                var channel = context.Channels.Include("Messages").FirstOrDefault(x => x.ChannelId == channelId);

                var messages = channel.Messages;

                context.Messages.RemoveRange(messages);
                context.Channels.Remove(channel);
                context.SaveChanges();
                ErrorSuccessNotifier.AddInfoMessage("Channel successfully removed");
                ErrorSuccessNotifier.ShowAfterRedirect = true;
                Response.Redirect(Request.RawUrl, false);
            }
            catch (Exception ex)
            {
                ErrorSuccessNotifier.AddErrorMessage(ex);
            }
        }
Esempio n. 41
0
        public bool Save(int id, string text)
        {
            bool result = false;
            using (context = new TwitterEntities())
            {
                var tweet = GetById(id);
                tweet.Body = text;

                context.Entry(tweet).State = EntityState.Modified;
                result = context.SaveChanges() > 0;
                Logger.Log.Debug("user ID:" + tweet.User_Id + " " + userDao.GetById(tweet.User_Id).Email + " edited a tweet ID:" + tweet.Id);
            }
            return result;
        }