public async Task AddOrUpdate(CustomerVipCacheModel model) { try { var customerVips = await LoadFromRedis(); var customerVip = customerVips.FirstOrDefault(c => c.Id == model.Id); if (customerVip == null) { customerVips.Add(model); } else { customerVip.Name = model.Name; customerVip.Color = model.Color; customerVip.SortOrder = model.SortOrder; customerVip.Profit = model.Profit; } await DistributedCache.Set(_cacheKey, customerVips); } catch (Exception exception) { _logger.Info(exception.ToString); } }
public CustomerVipModel(CustomerVipCacheModel model) { Id = model.Id; Name = model.Name; Color = model.Color; SortOrder = model.SortOrder; Profit = model.Profit; }