public async Task <ActionResult> AddMessage(Message param) { int Code; string str; User user = await userService.GetUserByIdAsync(param.UserId); if (await messageService.IsExistsMessageOnNewestByUserId(param.UserId)) { if (user.UserEmail != null && user.UserEmail != "") { param.Location = await LocationHelper.GetLocation(param.Location);//获取位置 param.MessageDate = DateTime.Now; Code = await messageService.AddEntityAsync(param) ? 200 : 500; if (param.TargetId != 0 && param.TargetUserId != Guid.Empty && param.TargetUserId != null) { bool ok = await sendEmail.ReplySendEmail(await messageService.GetMessageByIdAsync(param.TargetId), await messageService.GetMessageByIdAsync(param.MessageId), SendEmailType.回复留言);//发送邮件 if (ok) { str = Code == 200 ? "回复成功!" : "回复失败!请刷新页面后重试!"; } else { str = Code == 200 ? "回复成功,但是该回复并未通知到用户!" : "回复失败!请刷新页面后重试!"; } } else { str = Code == 200 ? "评论成功!" : "评论失败!请刷新页面后重试!"; }; } else { Code = 401; str = "您还未填写邮箱,请填写邮箱后再留言,谢谢!"; } } else { Code = 400; str = "您在1分钟已经提交过一次了,有什么想说的欢迎直接联系我哦!"; } return(Ok(new { code = Code, msg = str })); }