Example #1
0
        public virtual ActionResult Create(FormCollection collection)
        {
            TEntity entity = new TEntity();

            try {
                UpdateModelEntity(entity);
                OnBeforeCreate(entity);
                _repository.Add(entity);
                _repository.Save();
                return(ViewCreatePost(entity));
            } catch (Exception e) {
                ModelState.AddRulesViolations(entity);
                return(ViewCreatePostError(entity, e));
            }
        }
Example #2
0
        public virtual ActionResult Delete(TKey key, FormCollection collection)
        {
            TEntity entity = _repository.Get(key);

            if (entity == null)
            {
                return(ViewEntityNotFound(key));
            }

            try {
                OnBeforeDelete(entity);
                _repository.Delete(entity);
                _repository.Save();
                return(ViewDeletePost(entity));
            } catch (Exception e) {
                ModelState.AddRulesViolations(entity);
                return(ViewDeletePostError(entity, e));
            }
        }