Exemplo n.º 1
0
        public CrudReport Create(CreationRequest <TEdit> request)
        {
            var input        = request.Input;
            var notification = input.Notification;
            var model        = (TEntity)input.Target;

            _validator.Validate(model, notification);

            var    wasSaved = false;
            string editUrl  = null;


            if (notification.IsValid())
            {
                _saver.Create(model);
                wasSaved = true;
                editUrl  = _urls.UrlFor(model);

                _newEntityHandler.HandleNew(input);
            }

            var flattenedValue = _flattener.Flatten(model);

            return(new CrudReport(notification, model, flattenedValue)
            {
                success = wasSaved,
                editUrl = editUrl
            });
        }
Exemplo n.º 2
0
        public EntityFindViewModel Find(FindItemRequest <T> input)
        {
            var model = _repository.Find <T>(input.Id);
            var dto   = _flattener.Flatten(model);

            return(new EntityFindViewModel {
                Model = dto
            });
        }