Esempio n. 1
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));
            }
        }
Esempio n. 2
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));
     }
 }
Esempio n. 3
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));
     }
 }
Esempio n. 4
0
        // GET: Team/NewMessage/6
        public ActionResult NewMessage(int id)
        {
            MessageCreateForm createForm = new MessageCreateForm(id, "Employee");

            return(View(createForm));
        }
Esempio n. 5
0
        // GET: Task/NewSubject/6
        public ActionResult NewSubject(int id)
        {
            MessageCreateForm createForm = new MessageCreateForm(id, "Task");

            return(View(createForm));
        }