public IActionResult AddUserMessage([FromBody] FormMessage model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var errMsg = new StringBuilder(); if (model.name.Length == 0) { errMsg.Append("联系人不能为空"); } if (model.phone.Length == 0) { errMsg.Append("联系电话不能为空"); } if (model.content.Length == 0 && model.img_path.Count == 0) { errMsg.Append("内容和图片不能同时为空"); } if (errMsg.Length > 0) { return(this.CreateResult(null, res: 0, msg: errMsg.ToString())); } if (!message_dal.Add(model)) { return(this.CreateResult(null, res: 0)); } else { return(this.CreateResult(null)); } }
/// <summary> /// 发送消息 /// </summary> /// <param name="model"></param> /// <returns></returns> public string SendMessage(MessageModel model) { string err = CheckModel(model); if (ValidateHelper.IsPlumpString(err)) { return(err); } var dal = new MessageDal(); return(dal.Add(model) > 0 ? SUCCESS : "发送失败"); }
protected void submitMessage_OnServerClick(object sender, EventArgs e) { var dt = DateTime.Now; var time = dt.ToShortTimeString(); _messageDal.Add(new Message { Name = name.Value, Email = email.Value, Subject = msg_subject.Value, MessageText = message.Value, Time = time, }); lblResult.Text = "Message is sent"; }
public ResponseMessage <Message> Sent(MessageRequest message) { //todo dodac sprawdzenie czy nie jest na czarnej liscie var messageToAdd = new Message { Content = message.Content, Date = DateTime.Now, PlayerFrom = myPlayer, PlayerTo = new Player { Id = message.Receiver }, DisplayStatus = (int)MessageStatuses.New, ReadStatus = (int)MessageStatuses.New }; return(messageDal.Add(messageToAdd)); }
/// <summary> /// 增加一条新闻或通知 /// </summary> public void Add(TitleMessage model) { msgDal.Add(model); }