public ActionResult Create(Message message)
 {
     var list = _messageService.MessageTypeService.ListMessagesTypes(null);
     ViewData["List"] = list;
     if (_messageService.CreateMessage(message))
         return RedirectToAction("Index");
     return View(message);
 }
 public bool DeleteMessage(Message message)
 {
     try
     {
         _messagesRepository.DeleteMessage(message);
         return true;
     }
     catch(Exception ex)
     {
         _validationDictionary.AddError("_FORM","Message is not deleted"+ex.Message);
         return false;
     }
 }
        public bool CreateMessage(Message message)
        {
            try
            {
                var ctx = new CurrentContext();
                var client = ctx.CurrentClient;
                var userId = ctx.CurrentUserId;

                var messageType = MessageTypeService.GetMessageType(message.MessageTypeId);
                message.MessageType = messageType;
                //message.MessageTypeId;
                var user = ctx.GetSystemUser();
                message.Client = client;
                message.User = user;
                //message.User.UserId = userId;
                _messagesRepository.CreateMessage(message);
                return true;
            }
            catch (Exception ex)
            {
                _validationDictionary.AddError("_FORM", "Message not created" + ex.Message);
                 return false;
            }
        }
 public ActionResult Delete(Message message)
 {
     if (_messageService.DeleteMessage(message))
         return RedirectToAction("Index");
     return View(message);
 }