示例#1
0
        public ActionResult ShowMessages2()                     // Meddelandefunktion ny vy
        {
            MessageListViewModel viewmodel = new MessageListViewModel();
            var curentuserid = User.Identity.GetUserId();
            User currentuser = db.Users.Single(x => x.Id == curentuserid);

            foreach (Message item in currentuser.Messages)
            {
                MessageViewModel itemet = new MessageViewModel();
                itemet.messageid = item.id;
                itemet.Message = item.messagestring;
                itemet.Sender = item.sender;
                itemet.TimeReceived = item.time;

                if (item.displayed == true)
                {
                    viewmodel.ReadMessages.Add(itemet);
                }
                else
                {
                    viewmodel.UnreadMessaegs.Add(itemet);
                }
            }
            ViewBag.messagecontroller = TempData["Message"];
            return View(viewmodel);
        }
示例#2
0
文件: Repository.cs 项目: proxy51/LMS
        public MessageViewModel CreateMessage(string userid)
        {

            MessageViewModel view = new MessageViewModel();
            view.users = db.Users.ToList();
            if (RoleValues.Adminuser == true)
            {
                view.userisadmin = true;
                view.classlist = db.Classes.ToList();
            }
            return view;
        }
示例#3
0
文件: Repository.cs 项目: proxy51/LMS
 public MessageListViewModel ViewMessagesInBox(string userid)
 {
     MessageListViewModel viewmodel = new MessageListViewModel();
     User currentuser = db.Users.Single(x => x.Id == userid);
     foreach (Message item in currentuser.Messages)
     {
         MessageViewModel itemet = new MessageViewModel();
         itemet.messageid = item.id;
         itemet.Message = item.messagestring;
         itemet.Sender = item.sender;
         itemet.TimeReceived = item.time;
         if (item.displayed == true)
         {
             viewmodel.ReadMessages.Add(itemet);
         }
         else
         {
             viewmodel.UnreadMessaegs.Add(itemet);
         }
     }
     viewmodel.CurrentUserName = currentuser.UserName;
     SetUnreadMessages(userid);
     return viewmodel;
 }
示例#4
0
        public ActionResult Create(MessageViewModel model)
        {
            try
            {
                var userid = User.Identity.GetUserId();
                if (model.userid != null)
                {
                    repo.SendMessage(model.Message, model.userid,userid);
                    TempData["Message"] = "Message sent !";
                }
                else if (model.classid != 0)
                {
                    repo.SendClassMessage(model.Message, model.classid,userid);
                    TempData["Message"] = "Class message sent !";
                }
                else
                {
                    TempData["Message"] = "Some thing went wrong";
                }

                return RedirectToAction("Index");
            }
                
            catch
            {
                TempData["Message"] = "Some thing went wrong";
                return RedirectToAction("Index");
            }
        }
示例#5
0
 // GET: Message/Create
 public ActionResult Create()
 {
     MessageViewModel view = new MessageViewModel();
   var userid = User.Identity.GetUserId();
   view = repo.CreateMessage(userid); 
   return View(view);
     }
示例#6
0
文件: Repository.cs 项目: proxy51/LMS
        //Filemanager repo start



        
        public void MessageFunction(User currentuser, MessageListSectionModel MessageListSection)               // alex meddelandefunktion
        {
            foreach (Message messages in currentuser.Messages)
            {
                MessageViewModel MessageList = new MessageViewModel();

                MessageList.messageid = messages.id;
                MessageList.Message = messages.messagestring;
                MessageList.Sender = messages.sender;
                MessageList.TimeReceived = messages.time;

                if (messages.displayed == true)
                {
                    MessageListSection.ReadMessages.Add(MessageList);
                }
                else
                {
                    MessageListSection.UnreadMessages.Add(MessageList);
                }
            }

        }