Example #1
0
        public virtual ActionResult Delete(EntityDeleteModel model)
        {
            var entity = _admin.GetEntity(model.EntityName);
            if (entity == null)
            {
                return RedirectToAction("NotFound", new { entityName = model.EntityName });
            }

            var deleteOptions = DeleteOptionsHierarchyBuilder.Merge(
                entity,
                model.PropertiesDeleteOptions);

            try
            {
                var isSuccess = _entityService.Delete(entity, model.Key, deleteOptions);
                if (isSuccess)
                {
                    _notificator.Success(IlaroAdminResources.DeleteSuccess, entity.Verbose.Singular);

                    return RedirectToAction("Index", "Entities", new { entityName = model.EntityName });
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                _notificator.Error(ex.Message);
            }

            var entityRecord = _source.GetEntityRecord(entity, model.Key);

            model = new EntityDeleteModel(deleteOptions)
            {
                EntityRecord = entityRecord,
                RecordHierarchy = _hierarchySource.GetRecordHierarchy(entityRecord)
            };

            return View(model);
        }
Example #2
0
        public virtual ActionResult Delete(string entityName, string key)
        {
            var entity = _admin.GetEntity(entityName);
            if (entity == null)
            {
                return RedirectToAction("NotFound", new { entityName });
            }

            var entityRecord = _source.GetEntityRecord(entity, key);
            if (entityRecord == null)
            {
                return RedirectToAction("Index", "Entities", new { area = "IlaroAdmin", entityName });
            }

            var deleteOptions = DeleteOptionsHierarchyBuilder.GetHierarchy(entity);
            var model = new EntityDeleteModel(deleteOptions)
            {
                EntityRecord = entityRecord,
                RecordHierarchy = _hierarchySource.GetRecordHierarchy(entityRecord, deleteOptions)
            };

            return View(model);
        }