public async Task <JsonResult> SaveChangeProfile([Bind("Name,MobileNumber,QQNumber,EMail,Description")] ApplicationUserVM boVM) { if (string.IsNullOrEmpty(boVM.EMail)) { return(Json(new { result = false, message = "电子邮件必须填写!" })); } //var entity = await _userManager.FindByIdAsync(boVM.Id.ToString()); var thisUser = await _userManager.FindByNameAsync(User.Identity.Name); if (thisUser != null) { thisUser.ChineseFullName = EncodeFilterHelper.EncodeHtmlToNull(boVM.Name); thisUser.MobileNumber = boVM.MobileNumber; thisUser.Email = EncodeFilterHelper.EncodeHtml(boVM.EMail); thisUser.QQNumber = boVM.QQNumber; thisUser.Description = EncodeFilterHelper.EncodeHtmlToNull(boVM.Description); var update = await _userManager.UpdateAsync(thisUser); if (update.Succeeded) { var thisIntegrity = UserInfoIntegrity() + "%"; var thisUsername = GetCurrUserName(); return(Json(new { result = true, integrity = thisIntegrity, username = thisUsername })); } return(Json(new { result = false, message = "修改失败" })); } return(Json(new { result = false, message = "修改失败" })); }
public async Task <IActionResult> SubmitComment(YZ_CommodityCommentVM input) { if (input.Id == Guid.Empty) { return(Json(new { result = false, message = "留言失败!" })); } if (string.IsNullOrEmpty(input.Description)) { return(Json(new { result = false, message = "请填写留言内容!" })); } var user = GetUser(); var userComment = await GetCommodityComment(x => x.CommentUser == user && x.Commodity.Id == input.Id); if (userComment != null) { TimeSpan ts = (DateTime.Now - userComment.CreateTime); if (ts.Minutes < 3) { return(Json(new { result = false, message = "操作过于频繁,距离上一次留言时间过短\n请几分钟后再来留言吧!" })); } } if (user == null) { return(Json(new { result = false, noLogin = true, message = "您未登录无法进行留言,是否现在登录?" })); } var commodity = await GetCommodity(input.Id); if (commodity != null) { var newComment = new YZ_CommodityComment { CommentUser = user, Commodity = commodity, Description = EncodeFilterHelper.EncodeHtmlToNull(input.Description) }; var r = await _commodityComment.AddOrEditAndSaveAsyn(newComment); if (r) { if (commodity.AscriptionUser != user) { //发送消息通知 var message = "用户[ " + user.ChineseFullName + " ] 在 [ " + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + " ] 给您的商品 [ " + commodity.Name + " ] 留了言,可能是有意向购买,您可以点击链接查看。"; var notification = new Notification { Receiver = commodity.AscriptionUser, Name = "商品留言", Description = message, Link = "../../Home/GetCommodityDetail?id=" + commodity.Id, IsAbnormal = false, IsRead = false, NotificationSource = NotificationSourceEnum.App }; AppNotification.SendNotification(notification); } return(Json(new { result = true })); } return(Json(new { result = false, message = "留言失败!" })); } return(Json(new { result = false, message = "留言失败!" })); }