public async Task <IActionResult> Insert(string role_name) { try { var role = await context.AppRoles.SingleOrDefaultAsync(u => u.RoleName == role_name); if (role == null) { await context.AppRoles.AddAsync(new AppRole() { RoleName = role_name ?? "", }); await context.SaveChangesAsync(); logger.LogInformation(HttpContext.Session.GetString("who") + "新增角色成功。"); return(Json(new { code = 200, msg = "新增成功" })); } else { return(Json(new { code = 300, msg = "角色名称已存在" })); } } catch (Exception ex) { logger.LogInformation(HttpContext.Session.GetString("who") + "新增角色失败。" + ex.Message); return(Json(new { code = 300, msg = "新增失败" })); } }
public async Task <IActionResult> Insert(string button_name, string button_icon, string button_event, double button_sort, string button_color, string button_element_id) { try { var role = await context.AppButtons.SingleOrDefaultAsync(u => u.ButtonName == button_name); if (role == null) { await context.AppButtons.AddAsync(new AppButton() { ButtonName = button_name ?? "", ButtonIcon = button_icon ?? "", ButtonEvent = button_event ?? "", ButtonSort = button_sort, ButtonColor = button_color ?? "", ButtonElementId = button_element_id ?? "" }); await context.SaveChangesAsync(); logger.LogInformation(HttpContext.Session.GetString("who") + "新增按钮成功。"); return(Json(new { code = 200, msg = "新增成功" })); } else { logger.LogInformation(HttpContext.Session.GetString("who") + "按钮名称已存在。"); return(Json(new { code = 300, msg = "按钮名称已存在" })); } } catch (Exception ex) { logger.LogInformation(HttpContext.Session.GetString("who") + "新增按钮失败。" + ex.Message); return(Json(new { code = 300, msg = "新增失败" })); } }
public async Task <IActionResult> Insert(string menu_name, string menu_icon, string menu_url, string menu_type, double menu_sort, int parent_menu_id) { try { AppMenu appMenu = new AppMenu() { MenuIcon = menu_icon, MenuName = menu_name, MenuSort = menu_sort, MenuType = menu_type, MenuUrl = menu_url, ParentMenuId = parent_menu_id }; await context.AppMenus.AddAsync(appMenu); await context.SaveChangesAsync(); logger.LogError(HttpContext.Session.GetString("who") + "新增成功"); return(Json(new { code = 200, msg = "新增成功" })); } catch (Exception ex) { logger.LogError(HttpContext.Session.GetString("who") + "新增菜单出错:" + ex.Message); return(Json(new { code = 300, msg = "新增失败,请联系管理员" })); } }
public async Task <IActionResult> Insert(string CorpCode, string CorpName, string Fax, string Zip, string Email, string ContractPersonName, string ContractPersonPhone, string ContractPersonIdentity, string LawPersonName, string LawPersonPhone, string LawPersonIdentity, string Address, string TaxRqNumber, string Note) { try { var single = await context.AppCorps.SingleOrDefaultAsync(u => u.CorpCode == CorpCode); if (single == null) { single = await context.AppCorps.SingleOrDefaultAsync(u => u.CorpName == CorpName); if (single == null) { await context.AppCorps.AddAsync(new AppCorp() { CorpCode = CorpCode ?? "", CorpName = CorpName ?? "", Fax = Fax ?? "", Zip = Zip ?? "", Email = Email ?? "", ContractPersonName = ContractPersonName ?? "", ContractPersonPhone = ContractPersonPhone ?? "", ContractPersonIdentity = ContractPersonIdentity ?? "", LawPersonName = LawPersonName ?? "", LawPersonPhone = LawPersonPhone ?? "", LawPersonIdentity = LawPersonIdentity ?? "", Address = Address ?? "", TaxRqNumber = TaxRqNumber ?? "", Note = Note, Status = "编辑", CreationDate = DateTime.Now, CreationUser = HttpContext.Session.GetInt32("user_id") }); await context.SaveChangesAsync(); logger.LogInformation(HttpContext.Session.GetString("who") + "新增公司成功。"); return(Json(new { code = 200, msg = "新增成功" })); } else { return(Json(new { code = 300, msg = "公司名称已存在" })); } } else { return(Json(new { code = 300, msg = "公司代码已存在" })); } } catch (Exception ex) { logger.LogInformation(HttpContext.Session.GetString("who") + "新增公司失败。" + ex.Message); return(Json(new { code = 300, msg = "新增失败" })); } }
public async Task <IActionResult> InsertFixValueType(string code, string name) { try { var single = await context.AppFixvalueTypes.SingleOrDefaultAsync(u => u.FixvalueTypeCode == code); if (single == null) { await context.AppFixvalueTypes.AddAsync(new AppFixvalueType() { FixvalueTypeCode = code ?? "", FixvalueTypeName = name ?? "", CreationDate = DateTime.Now, CreationUser = HttpContext.Session.GetInt32("user_id"), Status = "有效" }); await context.SaveChangesAsync(); logger.LogInformation(HttpContext.Session.GetString("who") + "新增公共代码类型成功。"); return(Json(new { code = 200, msg = "新增成功" })); } else { logger.LogInformation(HttpContext.Session.GetString("who") + "公共代码类型代码已存在。"); return(Json(new { code = 300, msg = "公共代码类型代码已存在" })); } } catch (Exception ex) { logger.LogInformation(HttpContext.Session.GetString("who") + "新增公共代码类型失败。" + ex.Message); return(Json(new { code = 300, msg = "新增失败" })); } }
public async Task <IActionResult> Insert(int CorpId, string BankProvince, string BankCity, string BankName, string BankAccount, string BankNo, string Note) { try { await context.AppCorpBanks.AddAsync(new Models.AppCorpBank() { CorpId = CorpId, BankProvince = BankProvince ?? "", BankCity = BankCity ?? "", BankName = BankName ?? "", BankAccount = BankAccount ?? "", BankNo = BankNo ?? "", Note = Note, Status = "编辑", CreationDate = DateTime.Now, CreationUser = HttpContext.Session.GetInt32("user_id") }); await context.SaveChangesAsync(); logger.LogInformation(HttpContext.Session.GetString("who") + "新增公司银行账号信息成功。"); return(Json(new { code = 200, msg = "新增成功" })); } catch (Exception ex) { logger.LogInformation(HttpContext.Session.GetString("who") + "新增公司银行账号信息失败。" + ex.Message); return(Json(new { code = 300, msg = "新增失败" })); } }
public async Task <IActionResult> Insert(int CorpId, string DeptCode, string DeptName, string Note) { try { var single = await context.AppDepts.SingleOrDefaultAsync(u => u.DeptCode == DeptCode && u.CorpId == CorpId); if (single == null) { var single1 = await context.AppDepts.SingleOrDefaultAsync(u => u.DeptName == DeptName && u.CorpId == CorpId); if (single1 == null) { await context.AppDepts.AddAsync(new Models.AppDept() { CorpId = CorpId, DeptCode = DeptCode ?? "", DeptName = DeptName ?? "", Note = Note, Status = "编辑", CreationDate = DateTime.Now, CreationUser = HttpContext.Session.GetInt32("user_id") }); await context.SaveChangesAsync(); logger.LogInformation(HttpContext.Session.GetString("who") + "新增部门成功。"); return(Json(new { code = 200, msg = "新增成功" })); } else { return(Json(new { code = 300, msg = "该部门名称在该公司中已经存在" })); } } else { return(Json(new { code = 300, msg = "该部门代码在该公司中已经存在" })); } } catch (Exception ex) { logger.LogInformation(HttpContext.Session.GetString("who") + "新增部门失败。" + ex.Message); return(Json(new { code = 300, msg = "新增失败" })); } }
public async Task <IActionResult> GetNewsById(int news_id) { try { var single = await context.AppNews.SingleOrDefaultAsync(u => u.NewsId == news_id); if (single != null) { single.BrowseNumber = single.BrowseNumber + 1; context.AppNews.Update(single); await context.SaveChangesAsync(); var news = await(from n in context.AppNews join t in context.AppNewsTypes on n.NewsTypeId equals t.NewsTypeId where n.NewsId.Equals(news_id) select new { n.BrowseNumber, n.CreationDate, n.CreationUser, n.LastModifiedDate, n.LastModifiedUser, n.NewsAuthor, n.NewsContent, n.NewsCoverImageUrl, n.NewsId, n.NewsReleaseTime, n.NewsTitle, n.NewsTypeId, n.Status, t.NewsTypeName }).SingleOrDefaultAsync(); return(Json(new { code = 0, msg = "查询成功", count = 1, data = news })); } else { return(Json(new { code = 1, msg = "查询不到该新闻", count = 0, data = new { } })); } } catch (Exception ex) { return(Json(new { code = 1, msg = ex.Message, count = 0, data = new { } })); } }
public async Task <IActionResult> Insert(int CorpId, int DeptId, int PostId, string UserCode, string UserName, string Phone, string Email, string Address) { try { var single = await context.AppUsers.SingleOrDefaultAsync(u => u.UserCode == UserCode); if (single == null) { await context.AppUsers.AddAsync(new Models.AppUser() { CorpId = CorpId, DeptId = DeptId, PostId = PostId, UserCode = UserCode ?? "", UserName = UserName ?? "", Phone = Phone ?? "", Email = Email ?? "", Address = Address ?? "", Status = "编辑", Password = Helper.EncodeHelper.MD5Hash(UserCode + "_" + DateTime.Now.Year), CreationDate = DateTime.Now, CreationUser = HttpContext.Session.GetInt32("user_id") }); await context.SaveChangesAsync(); logger.LogInformation(HttpContext.Session.GetString("who") + "新增用户成功。"); return(Json(new { code = 200, msg = "新增成功" })); } else { return(Json(new { code = 300, msg = "该账户已经存在" })); } } catch (Exception ex) { logger.LogInformation(HttpContext.Session.GetString("who") + "新增用户失败。" + ex.Message); return(Json(new { code = 300, msg = "新增失败" })); } }