public JsonResult AddSendAuth(InputTemeplate inputTemeplate) { var userInfo = DBManager.Instance.GetUser(UserName); if (userInfo != null && inputTemeplate.Type != null && inputTemeplate.Name != null) { var barkKey = typeof(BarkSendTemplate).GetCustomAttributes(typeof(SendMethodKeyAttribute), false).OfType <SendMethodKeyAttribute>().First().Key; if (barkKey == inputTemeplate.Type) { return(Fail(406, "BARK通道勿手动添加,请使用APP添加BARK地址绑定")); } else { var authInfo = inputTemeplate.TemplateToAuth(); var sendAuth = new SendAuthInfo() { UserId = userInfo.Id, SendMethodTemplate = inputTemeplate.Type, AuthData = authInfo, Name = inputTemeplate.Name, Key = Guid.NewGuid().ToString("N").ToUpper(), CreateTime = DateTime.Now, ModifyTime = DateTime.Now, }; DBManager.Instance.DBase.Insert(sendAuth); return(OK(sendAuth)); } } return(Fail()); }
public JsonResult ModifySendAuth(InputTemeplate inputTemeplate) { var userInfo = DBManager.Instance.GetUser(UserName); if (userInfo != null) { var oldSendInfo = DBManager.Instance.DBase.Query <SendAuthInfo>().FirstOrDefault(e => e.Id == inputTemeplate.SendAuthId); if (oldSendInfo != null && inputTemeplate.Name != null) { oldSendInfo.Name = inputTemeplate.Name; oldSendInfo.AuthData = inputTemeplate.TemplateToAuth(); oldSendInfo.ModifyTime = DateTime.Now; DBManager.Instance.DBase.Update(oldSendInfo); } return(OK(oldSendInfo)); } return(Fail()); }
public JsonResult ModifySendAuth(InputTemeplate inputTemeplate) { var userInfo = DBManager.Instance.GetUser(UserName); if (userInfo != null) { var barkTemplateAttribute = typeof(BarkSendTemplate).GetCustomAttributes(typeof(SendMethodKeyAttribute), false).OfType <SendMethodKeyAttribute>().First(); var oldSendInfo = DBManager.Instance.DBase.Query <SendAuthInfo>().FirstOrDefault(e => e.Id == inputTemeplate.SendAuthId); if (oldSendInfo != null && inputTemeplate.Name != null) { oldSendInfo.Name = inputTemeplate.Name; oldSendInfo.AuthData = inputTemeplate.TemplateToAuth(); oldSendInfo.ModifyTime = DateTime.Now; DBManager.Instance.DBase.Update(oldSendInfo); } return(OK(oldSendInfo)); } return(Fail()); }
public JsonResult AddSendAuth(InputTemeplate inputTemeplate) { var userInfo = DBManager.Instance.GetUser(UserName); if (userInfo != null && inputTemeplate.Key != null && inputTemeplate.Name != null) { var authInfo = inputTemeplate.TemplateToAuth(); var sendAuth = new SendAuthInfo() { UserId = userInfo.Id, SendMethodTemplate = inputTemeplate.Key, AuthData = authInfo, Name = inputTemeplate.Name, CreateTime = DateTime.Now, ModifyTime = DateTime.Now, }; DBManager.Instance.DBase.Insert(sendAuth); return(OK(sendAuth)); } return(Fail()); }