Пример #1
0
 public JsonResult Archive(int id)
 {
     Message message = serviceMessage.Archive(id, CurrentUser);
     var data = new VMMessage()
         {
             Body = message.Body,
             Sender = message.CreatedBy.DisplayName,
             SentOn = message.CreatedOn.ToString("dd-MMM-yyyy hh:mm"),
             Title = message.Title,
             Id = message.Id
         };
     var result = new JsonResult() { Data = data };
     return result;
 }
Пример #2
0
        public IEnumerable<VMMessage> GetFolder(int userId, string folderName)
        {
            List<VMMessage> result = new List<VMMessage>();
            List<MessageBox> messages = null;
            switch (folderName.ToLower())
            {
                case "inbox":
                    messages = GetBox(userId,BoxType.Inbox).ToList();
                    break;
                case "outbox":
                    messages = GetBox(userId, BoxType.Outbox).ToList();
                    break;
                case "archive":
                    messages = GetBox(userId,true).ToList();
                    break;
            }

            foreach (MessageBox boxMessage in messages)
            {
                VMMessage msg = new VMMessage(boxMessage);

                result.Add(msg);
            }

            return result;
        }
Пример #3
0
 public VMMessage GetByBoxId(int boxId)
 {
     var boxMessage = repositoryMessage.GetByBoxId(boxId);
     VMMessage result = new VMMessage(boxMessage,true);
     return result;
 }
Пример #4
0
        public JsonResult Send(string to, string body, string title, int?  replyTo)
        {
            IEnumerable<int> destinationIds = this.serviceMessage.GetDestinationIds(to);
            Message message = new Message() { Body = body, Title = title };
            message = this.serviceMessage.Send(message,CurrentUser, destinationIds, replyTo);
            //todo  : use automapper
            VMMessage vm = new VMMessage(message);

            var result = new JsonResult() { Data = vm, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
            return result;
        }