public async Task <IActionResult> SetOrderColumns(int[] order, eTablesType etype) { ConfigVistaUsuario config = new ConfigVistaUsuario(); string optionTableName = Enum.GetName(typeof(eTablesType), etype); string ids = String.Join(",", order.Select(p => p.ToString()).ToArray()); try { //si debo actualizar if (_context.ConfigVistas.Any(d => d.Usuario == User.Identity.Name)) { config = _context.ConfigVistas.FirstOrDefault(d => d.Usuario == User.Identity.Name); config.TipoTabla = optionTableName; config.Usuario = User.Identity.Name; config.OrderColumns = ids; var result = await _context.SaveChangesAsync(); } //si debo crear un nuevo registro. config.TipoTabla = optionTableName; config.Usuario = User.Identity.Name; config.OrderColumns = ids; _context.ConfigVistas.Add(config); var r = await _context.SaveChangesAsync(); } catch (Exception ex) { throw; } return(Ok()); }
public IActionResult SetCacheReorderColumns(int[] order, eTablesType etype) { var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromDays(30)); ConfigUserTable configUserTable = new ConfigUserTable(); configUserTable.User = User.Identity.Name; configUserTable.OrderColumTable = order; configUserTable.TablesType = etype; string optionTableName = Enum.GetName(typeof(eTablesType), etype); optionTableName = User.Identity.Name + "--" + optionTableName; _memoryCache.Set(optionTableName, configUserTable, cacheEntryOptions); return(Ok(new { success = true, response = true })); }