コード例 #1
0
        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());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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());
            }
        }
コード例 #4
0
        public virtual async Task <ActionResult> ClearCacheAsync()
        {
            await MixService.RemoveCacheAsync(typeof(TModel));

            return(NoContent());
        }