Exemple #1
0
        public Guid?SendMessage(IncomingMessageViewModel message)
        {
            try
            {
                int    userID               = HttpContext.Current.User.Identity.GetUserId <int>();
                string nickName             = HttpContext.Current.User.Identity.NickName();
                ChatMessageRepository cRepo = new ChatMessageRepository();
                var messageSurrogate        = cRepo.CreateNewInstance(message.Message);
                //messageSurrogate.AttachType = (byte)message.AttachType;

                messageSurrogate.ReplyToMessageID = message.ReplyToMessageID;
                messageSurrogate.UserID           = userID;
                messageSurrogate.ReceivedDate     = DateTime.Now;
                cRepo.Save(messageSurrogate);
                OutgoingMessageViewModel outgoingMessage = messageSurrogate;
                Clients.All.IncomingMessage(outgoingMessage);
                //if ((AttachType)messageSurrogate.AttachType != AttachType.None)
                //{
                //    this.Clients.Caller.StartMessageFileUpload(messageSurrogate.ID);
                //}
                return(messageSurrogate.ID);
            }
            catch
            {
                return(null);
            }
        }