Exemple #1
0
        public override IActionResult Delete(int id)
        {
            var entity = Service.ByID(id);

            if (entity == null)
            {
                return(NotFound());
            }

            entity.Icon = entity.Icon.GetFullPath("Storage:Images");
            if (!string.IsNullOrEmpty(entity.Icon))
            {
                if (System.IO.File.Exists(entity.Icon))
                {
                    System.IO.File.Delete(entity.Icon);
                }
            }

            CultureViewModel model = Activator.CreateInstance <CultureViewModel>();

            model.GetKeys(entity);

            if (Service.TryDelete(entity))
            {
                model.AfterDeleteEntity(entity);
                if (!TranslateService.HasTranslationTable(model.Code))
                {
                    TranslateService.DeleteTranslationTable(model.Code);
                }
            }

            CultureHelper.ReLoad();

            return(Ok(OperationType.Delete));
        }