protected void SendMessageButton_Click(object sender, EventArgs e) { try { ErrorPanelCtrl.Visible = false; SuccessPanelCtrl.Visible = false; ShoutboxMessage Mess = new ShoutboxMessage(); Mess.Message = Message2.Text; Mess.Username = Member.CurrentName; Mess.TrySend(Message.MaxLength); Setup(true); } catch (MsgException ex) { ErrorPanelCtrl.Visible = true; ErrorPanelCtrl.ErrorText = ex.Message; ErrorPanelCtrl.DataBind(); } catch (SuccessMsgException ex) { SuccessPanelCtrl.Visible = true; SuccessPanelCtrl.SuccessText = ex.Message; SuccessPanelCtrl.DataBind(); } }
public ShoutboxMessageViewModel(ShoutboxMessage message) { MessageID = message.ID; AuthorID = message.AuthorID; AuthorImageURL = message.Author.ImgUrl; AuthorName = message.Author.Name; Message = message.Message; Day = message.Day; TimeUTCMilliseconds = new JavascriptDate(message.Time).JavascriptMilliseconds; }
public ShoutboxMessage SendMessage(string content, Entity author, ShoutboxMessage parent) { var message = new ShoutboxMessage() { AuthorID = author.EntityID, ChannelID = parent.ChannelID, ParentID = parent.ID, Message = content, Time = DateTime.Now, Day = GameHelper.CurrentDay }; shoutboxMessageRepository.Add(message); ConditionalSaveChanges(shoutboxMessageRepository); return(message); }
public JsonResult WriteMessage(int channelID, int?parentID, string content) { try { var channel = shoutboxChannelRepository.GetById(channelID); var author = SessionHelper.CurrentEntity; MethodResult result = shoutBoxService.CanSendMessage(content, channel, author); if (result.IsError) { return(JsonError(result)); } ShoutboxMessage message = null; if (parentID.HasValue) { var parent = shoutboxMessageRepository.GetById(parentID.Value); if (parent == null) { return(JsonError("Error")); } message = shoutBoxService.SendMessage(content, author, parent); } else { message = shoutBoxService.SendMessage(content, author, channel); } return(JsonData(new ShoutboxMessageViewModel(message))); } catch (UserReadableException e) { return(JsonError(e)); } catch (Exception) { return(JsonError("Unspecified error ocurred")); throw; } }