public HttpResponseMessage MessageViewed(MessageRead request)
        {
            MessageViewed temp = db.MessagesViewed.SingleOrDefault(mv => mv.EmployeeID.Equals(request.employeeID) && mv.MessageID.Equals(request.messageID));

            temp.DateViewed = request.time;

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
        public HttpResponseMessage MessageViewed(MessageRead request)
        {
            using (var db = new TimeClockContext())
            {
                /******************************************************************************    TODO ITEM    *********************************/
                //Need to mark the corresponding message read.
                MessageViewed temp = db.MessagesViewed.SingleOrDefault(mv => mv.EmployeeID.Equals(request.employeeID) && mv.MessageID.Equals(request.messageID));

                temp.DateViewed = request.time;

                return(new HttpResponseMessage(HttpStatusCode.Created));
            }
        }
        //pull list of messages needs a response type

        public HttpResponseMessage <IEnumerable <Messages> > GetMessages(string id)
        {
            using (var db = new TimeClockContext())
            {
                Employee emp = db.Employees.SingleOrDefault(e => e.EmployeeID.Equals(id));

                var messages = emp.Messages;
                messages.OrderBy(m => m.DateCreated);

                List <Messages> returnMessages = new List <Messages>();

                foreach (Message mes in messages)
                {
                    bool isViewed = true;

                    MessageViewed tempMV = db.MessagesViewed.SingleOrDefault(mv => mv.EmployeeID.Equals(id) && mv.MessageID.Equals(mes.MessageID));

                    if (!tempMV.DateViewed.HasValue)
                    {
                        isViewed = false;
                    }

                    Messages temp = new Messages()
                    {
                        MessegeID = mes.MessageID.ToString(),
                        Date      = mes.DateCreated.ToString(@"MM\/dd\/yy"),
                        From      = mes.Manager.FirstName + " " + mes.Manager.LastName,
                        Subject   = mes.Subject,
                        isViewed  = isViewed
                    };

                    returnMessages.Add(temp);
                }


                return(new HttpResponseMessage <IEnumerable <Messages> >(returnMessages));
            }

            /* new two new types messageData and messageList
             * messageData() { messages = List<messageList>() { messageId , Date, From, Subject } }
             */
        }
        //pull list of messages needs a response type

        public HttpResponseMessage <MessagesResponse> GetMessages(string id)

        {
            Employee emp = db.Employees.SingleOrDefault(e => e.EmployeeID.Equals(id));

            var messages = emp.Messages;

            messages.OrderBy(m => m.DateCreated);

            List <Messages> returnMessages = new List <Messages>();

            foreach (Message mes in messages)
            {
                bool isViewed = true;

                MessageViewed tempMV = db.MessagesViewed.SingleOrDefault(mv => mv.EmployeeID.Equals(id) && mv.MessageID.Equals(mes.MessageID));

                if (tempMV != null && !tempMV.DateViewed.HasValue)
                {
                    isViewed = false;
                }

                Messages temp = new Messages()
                {
                    MessageID = mes.MessageID.ToString(),
                    Date      = mes.DateCreated.ToString(@"MM\/dd\/yy"),
                    From      = mes.Manager.FirstName + " " + mes.Manager.LastName,
                    Subject   = mes.Subject,
                    isViewed  = isViewed
                };

                returnMessages.Add(temp);
            }
            return(new HttpResponseMessage <MessagesResponse>(new MessagesResponse()
            {
                messages = returnMessages
            }));
        }