public virtual async Task <ActionResult> ClearCacheAsync(string id) { string key = $"_{id}"; key += !string.IsNullOrEmpty(_lang) ? $"_{_lang}" : string.Empty; await MixService.RemoveCacheAsync(typeof(TModel), key); return(NoContent()); }
public override async Task <RepositoryResponse <bool> > RemoveRelatedModelsAsync(DeleteViewModel view, MixCmsContext _context = null, IDbContextTransaction _transaction = null) { var result = new RepositoryResponse <bool>() { IsSucceed = true }; var removeDataIds = _context.MixAttributeSetValue.Where(m => m.AttributeFieldId == Id).Select(m => m.DataId).ToList(); var removeFieldValues = await MixAttributeSetValues.DeleteViewModel.Repository.RemoveListModelAsync(false, f => f.AttributeFieldId == Id); ViewModelHelper.HandleResult(removeFieldValues, ref result); if (result.IsSucceed) { foreach (var item in removeDataIds) { _ = MixService.RemoveCacheAsync(typeof(MixAttributeSetData), item); } } return(result); }
public async Task <ActionResult <TView> > Duplicate(string id) { var getData = await GetSingleAsync(id); if (getData.IsSucceed) { var data = getData.Data; var idProperty = ReflectionHelper.GetPropertyType(data.GetType(), "Id"); switch (idProperty.Name.ToLower()) { case "int32": ReflectionHelper.SetPropertyValue(data, new JProperty("id", 0)); break; default: ReflectionHelper.SetPropertyValue(data, new JProperty("id", default)); break; } var saveResult = await data.SaveModelAsync(true); if (saveResult.IsSucceed) { string key = $"_{id}"; key += !string.IsNullOrEmpty(_lang) ? $"_{_lang}" : string.Empty; await MixService.RemoveCacheAsync(typeof(TModel), key); return(Ok(saveResult.Data)); } else { return(BadRequest(saveResult.Errors)); } } else { return(NoContent()); } }
public virtual async Task <ActionResult> ClearCacheAsync() { await MixService.RemoveCacheAsync(typeof(TModel)); return(NoContent()); }