public ActionResult SendMessage(string id)
 {
     Message m = new Message();
     if (id != null)
         m.Receiver = chRep.userDB.getUser(id).UserId;
     MessageSendDM dm = new MessageSendDM(m);
     return View(dm);
 }
 public MessageFormViewModel(Message Message)
 {
     channelRepository = new ChannelRepository();
     this.Message = Message;
     ProfileImage = getGravatar(channelRepository.userDB.getUser(Message.UserId).aspnet_Membership.Email);
     Username = channelRepository.userDB.getUser(Message.UserId).UserName;
     Attachment = null;
 }
 public MessageSendDM(Message Message)
 {
     channelRepository = new ChannelRepository();
     this.Message = Message;
     if (Message.Receiver.HasValue)
     {
         Receivers = new SelectList(channelRepository.userDB.getAllUsers(), "UserID", "UserName", (Guid) Message.Receiver);
     }
     else
     {
         Receivers = new SelectList(channelRepository.userDB.getAllUsers(), "UserID", "UserName");
     }
 }
        public ActionResult SendMessage(string id, FormCollection collection)
        {
            // TODO: Add insert logic here
            Message newMessage = new Message();
            newMessage.ChannelName = id;
            try
            {
                String[] wl = { "Content" };
                UpdateModel(newMessage, wl);
                chRep.sendMessage(newMessage, User.Identity.Name);

                return RedirectToAction("Display", new { id = id });
            }
            catch
            {
                return View("Error");
            }
        }
 public ActionResult SendMessage(string id)
 {
     Message m = new Message();
     m.ChannelName = id;
     return View(m);
 }
        internal void lookupUserMessages()
        {
            foreach (aspnet_User reciver in chRep.userDB.getAllUsers())
            {
                String codeword = "d " + reciver.UserName;
                SMS sms = getFromCodeword(codeword);
                if (sms.status == "received")
                {
                    foreach (aspnet_User sender in chRep.userDB.getAllUsers())
                    {
                        if (sender.MobileAlias == sms.SND)
                        {
                            Message m = new Message();
                            m.Receiver = reciver.UserId;
                            m.Content = sms.TXT.TrimStart(codeword.ToCharArray());

                            try
                            {
                                if (chRep.userDB.getUser((Guid)m.Receiver).MobileAlias != null)
                                    sendSMS("d " + chRep.userDB.getUser(m.UserId).UserName + ": " + m.Content, chRep.userDB.getUser((Guid)m.Receiver).MobileAlias);
                            }
                            catch { }

                            chRep.sendMessage(m, sender.UserName);
                        }
                    }
                }
            }

            foreach (Channel c in chRep.showAllChannels())
            {
                String codeword = "c " + c.Name;
                SMS sms = getFromCodeword(codeword);
                if (sms.status == "received")
                {
                    foreach (aspnet_User sender in chRep.userDB.getAllUsers())
                    {
                        if (sender.MobileAlias == sms.SND)
                        {
                            if (sms.TXT == "c " + c.Name)
                            {
                                Message m = chRep.getAllMessages(c.Name).ToList().First();
                                if (m != null)
                                {
                                    sendSMS(chRep.userDB.getUser(m.UserId).UserName + ": " + m.Content, sender.MobileAlias);
                                }
                            }
                            else
                            {
                                Message m = new Message();
                                m.ChannelName = c.Name;
                                m.Content = sms.TXT.TrimStart(codeword.ToCharArray());;
                                chRep.sendMessage(m, sender.UserName);
                            }
                        }
                    }
                }
            }
        }
		private void detach_Messages1(Message entity)
		{
			this.SendPropertyChanging();
			entity.aspnet_User1 = null;
		}
		private void attach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.aspnet_User = this;
		}
		private void detach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Channel = null;
		}
		private void attach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Channel = this;
		}
 partial void DeleteMessage(Message instance);
 partial void UpdateMessage(Message instance);
 partial void InsertMessage(Message instance);
 public void sendMessage(Message newMessage, string username)
 {
     newMessage.Timestamp = DateTime.Now;
     newMessage.UserId = userDB.getUser(username).UserId;
     db.Messages.InsertOnSubmit(newMessage);
     db.SubmitChanges();
 }