Exemplo n.º 1
0
        public IActionResult Create(Message m)
        {
            AcademyChatContext acc = new AcademyChatContext();

            acc.Message.Add(m);
            acc.SaveChanges();

            return(View());
        }
Exemplo n.º 2
0
        public IActionResult Create(Message m)
        {
            m.SendTime = DateTime.Now;
            db.Message.Add(m);
            db.SaveChanges();

            var msg = (from mes in db.Message
                       where mes.PrivateMessage == false
                       orderby mes.SendTime descending
                       select mes).ToList();

            return(View("index", msg));
        }
Exemplo n.º 3
0
        public async Task SendMessage(string user, string message)
        {
            //messagen talletus db:hen tähän
            AcademyChatContext db       = new AcademyChatContext();
            DateTime           tempTime = DateTime.Now;
            await Clients.All.SendAsync("ReceiveMessage", user, message, tempTime);

            var sender = (from s in db.Person
                          where s.NickName == user
                          select s).FirstOrDefault();

            Message m = new Message();

            m.FromPerson     = sender;
            m.Subject        = "testisubject";
            m.MessageText    = message;
            m.SendTime       = tempTime;
            m.PrivateMessage = false;
            db.Message.Add(m);
            db.SaveChanges();
        }