private Service_MessageBoard GetOldEntity(Service_MessageBoard entity) { try { return(entity.ToJson().ToObject <Service_MessageBoard>()); } catch (Exception ex) { throw new Exception(ex.Message); } }
public IActionResult Save(string uuid, [FromBody] JObject fromValue) { long logId = 0; try { logId = BaseApiManager.SaveLogs(uuid, fromValue); if (!IsUuid(uuid)) { return(Error(logId, "verify uuid fail!")); } bool isParams = IsSaveParams(fromValue); var entityInterfaceAccount = GetInterfaceAccountByUuid(uuid); string companyId = entityInterfaceAccount.CompanyID; string ipAddress = Net.Ip; string name = GetJObjectValue(fromValue, "name"); string phone = GetJObjectValue(fromValue, "phone"); string email = GetJObjectValue(fromValue, "email"); string address = GetJObjectValue(fromValue, "address"); string content = GetJObjectValue(fromValue, "content"); if (string.IsNullOrWhiteSpace(name)) { return(Error("昵称不能为空!")); } if (string.IsNullOrWhiteSpace(content)) { return(Error("内容不能为空!")); } if (!Utility.IsMobilePhone(phone)) { return(Error("手机号码格式不正确!")); } if (!Utility.IsEmail(email)) { return(Error("邮箱地址格式不正确!")); } var entityConfig = ConfigService.GetConfig(SystemID, companyId); if (entityConfig != null) { string Shielding = entityConfig.Shielding; if (!string.IsNullOrWhiteSpace(Shielding)) { string[] keyword = Shielding.Split("|"); if (!IsKeyword(keyword, content)) { return(Error("内容有非法虑字!")); } } } var entity = new Service_MessageBoard() { SystemID = SystemID, CompanyID = companyId, Name = name, Phone = phone, Email = email, Address = address, Content = content, IpAddress = ipAddress }; var result = MessageBoardService.SaveMessageBoard(entity); if (result) { return(Success(logId, "ok")); } else { return(Error(logId, "fail")); } } catch (Exception ex) { return(Error(logId, ex.Message)); } }