Пример #1
0
 public Message(CD.Message message)
 {
     CS.EmployeeService repoEmployee = new CS.EmployeeService();
     Id     = message.Id;
     Date   = message.Date;
     Title  = message.Title;
     Text   = message.Text;
     Sender = new CurrentOn(repoEmployee.Get(message.EmployeeId));
 }
Пример #2
0
        // GET: Message/Answer/12
        public ActionResult Answer(int id)
        {
            MessageService repoMessage = new MessageService();

            CD.Message        m    = repoMessage.Get(id);
            AnswerMessageForm form = new AnswerMessageForm(id, m.Title);

            return(View(form));
        }
Пример #3
0
 internal static G.Message ToGlobal(this C.Message entity)
 {
     return(new G.Message
     {
         Id = entity.Id,
         Title = entity.Title,
         Created = entity.Created,
         Body = entity.Body,
         Author = entity.Author,
         Parent = entity.Parent
     });
 }
Пример #4
0
 public ViewForm(C.Message message, IEnumerable <ViewForm> Children)
 {
     Id           = (int)message.Id;
     Title        = message.Title;
     Message      = message.Body;
     Parent       = message.Parent;
     Author       = EmployeeService.Get(message.Author);
     CreationTime = message.Created;
     Documents    = DocumentService.GetForMessage((int)message.Id).Select(d => new Doc.ListForm {
         Name = d.Filename, Id = (int)d.Id
     });
     this.Children = Children;
 }
Пример #5
0
        public PartialViewResult AjaxAnswer(int id, AnswerMessageForm collection)
        {
            MessageService repoMessage = new MessageService();

            CD.Message answer = repoMessage.Answer(new CD.Message()
            {
                Title      = collection.Title,
                Text       = collection.Message,
                EmployeeId = UserSession.CurrentUser.Id
            }, collection.MessageId);
            Subject subject = new Subject(repoMessage.GetConversation(id).Select(m => new MessageListItem(new M.Message(m))));

            return(PartialView("_Subject", subject));
        }
Пример #6
0
 internal static G.Message ToGlobal(this C.Message message)
 {
     if (message == null)
     {
         return(null);
     }
     return(new G.Message
     {
         Id = message.Id,
         Title = message.Title,
         Date = message.Date,
         Text = message.Text,
         EmployeeId = message.EmployeeId
     });
 }
 public MailboxForm(C.Message m, int MyId)
 {
     Message  = new ViewForm(m);
     Project  = MessageService.GetProjectForMessage((int)m.Id).FirstOrDefault();
     Team     = MessageService.GetTeamForMessage((int)m.Id).FirstOrDefault();
     Task     = MessageService.GetTaskForMessage((int)m.Id).FirstOrDefault();
     Employee = Message.Author;
     Form     = new SendForm {
         ToEmployee = (Task == null && Project == null && Team == null) ? Employee.Employee_Id : null,
         ToTask     = Task?.Id,
         ToTeam     = Team?.Id,
         ToProject  = Project?.Id,
         ReplyTo    = Message.Id
     };
     IsReplied = MessageService.IsMessageRepliedByEmployee((int)m.Id, MyId);
 }
Пример #8
0
        public PartialViewResult AjaxAnswer(int id, AnswerMessageForm collection)
        {
            MessageService  repoMessage = new MessageService();
            EmployeeService repoEmp     = new EmployeeService();

            CD.Message answer = repoMessage.Answer(new CD.Message()
            {
                Title      = collection.Title,
                Text       = collection.Message,
                EmployeeId = UserSession.CurrentUser.Id
            }, collection.MessageId);
            IEnumerable <MessageListItem> messages     = repoMessage.GetConversation(id).Select(m => new MessageListItem(new M.Message(m)));
            IEnumerable <M.CurrentOn>     participants = repoEmp.GetByMessageId(id).Select(e => new M.CurrentOn(e));
            Messaging messaging = new Messaging(messages, participants);

            return(PartialView("_Messaging", messaging));
        }
Пример #9
0
        public ActionResult Create(MessageCreateForm collection)
        {
            try
            {
                int receiverId = 0;
                if (!Int32.TryParse(collection.ReceiverId, out receiverId))
                {
                    EmployeeService repoEmp = new EmployeeService();
                    receiverId = repoEmp.Get().Where(e => e.Email == collection.ReceiverId).SingleOrDefault().Id;
                }
                if (ModelState.IsValid && receiverId != 0)
                {
                    MessageService repoMessage = new MessageService();
                    CD.Message     message     = new CD.Message(
                        collection.Title,
                        collection.Text,
                        UserSession.CurrentUser.Id
                        );
                    switch (collection.ReceiverKind)
                    {
                    case "Employee":
                        message = repoMessage.SendToEmployee(message, receiverId);
                        break;

                    case "Team":
                        message = repoMessage.SendToTeam(message, receiverId);
                        break;

                    default:
                        return(View(collection));
                    }
                    return(RedirectToAction("Index", new { id = message.Id }));
                }
                return(View(collection));
            }
            catch
            {
                return(View(collection));
            }
        }
Пример #10
0
 public ActionResult NewMessage(int id, MessageCreateForm collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             MessageService repoMessage = new MessageService();
             CD.Message     message     = new CD.Message(
                 collection.Title,
                 collection.Text,
                 UserSession.CurrentUser.Id
                 );
             message = repoMessage.SendToEmployee(message, id);
             return(RedirectToAction("Details", new { controller = "Message", id = message.Id }));
         }
         return(View(collection));
     }
     catch
     {
         return(View(collection));
     }
 }
Пример #11
0
 public ActionResult NewSubject(int id, MessageCreateForm collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             MessageService repoMessage = new MessageService();
             CD.Message     message     = new CD.Message(
                 collection.Title,
                 collection.Text,
                 UserSession.CurrentUser.Id
                 );
             message = repoMessage.SendToTask(message, id);
             return(RedirectToAction("Subject", new { id = message.Id }));
         }
         return(View(collection));
     }
     catch
     {
         return(View(collection));
     }
 }
Пример #12
0
 public ActionResult Answer(int id, AnswerMessageForm collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             MessageService repoMessage = new MessageService();
             CD.Message     m           = repoMessage.Answer(new CD.Message()
             {
                 Title      = collection.Title,
                 Text       = collection.Message,
                 EmployeeId = UserSession.CurrentUser.Id
             }, id);
             return(RedirectToAction("Details", new { id = m.Id }));
         }
         return(View(collection));
     }
     catch
     {
         return(View(collection));
     }
 }
Пример #13
0
 public ViewForm(C.Message message) : this(message, null)
 {
 }