public void AddOperationLog(AdminOperationLog log) { using (ApplicationDbContext ctx = new ApplicationDbContext()) { ctx.OperationLogs.Add(log); ctx.SaveChanges(); } }
/// <summary> /// /// </summary> /// <param name="operUserId">操作者的用户Id</param> /// <param name="operName">操作的名称,一般是对应的菜单</param> /// <param name="description">才做描述</param> /// <param name="userId">可空,被操作者的userId</param> public void AddOperationLog(string operUserId, string operName, string description, string userId = "") { using (ApplicationDbContext ctx = new ApplicationDbContext()) { AdminOperationLog log = new AdminOperationLog() { CreationDate = DateTime.Now, Description = description, OperationName = operName, OperUserId = operUserId, UserId = userId }; ctx.OperationLogs.Add(log); ctx.SaveChanges(); } }