Пример #1
0
        protected override void ExecuteDeleteMethod(TModel model, IBaseUnitOfWorkEf unitOfWork)
        {
            var repo = unitOfWork.GetGenericRepo <TModel>();

            repo.AttachEntity(model);

            repo.Delete((TModel)model);
        }
Пример #2
0
        protected override TViewModel ExecuteGetById(TIdentity id, IBaseUnitOfWorkEf unitOfWork)
        {
            var repo = unitOfWork.GetGenericRepo <TModel>();

            var model = repo.GetById(id);

            return(ToViewModel(model));
        }
Пример #3
0
        protected override TViewModel ExecuteUpdateMethod(TModel model, IBaseUnitOfWorkEf unitOfWork)
        {
            var repo = unitOfWork.GetGenericRepo <TModel>();

            repo.AttachEntity((TModel)model);

            repo.Update((TModel)model);

            return(ToViewModel(model));
        }
Пример #4
0
        protected override SearchResults <TViewModel> ExecuteGetList(SortAndFilterData sortAndFilter, IBaseUnitOfWorkEf unitOfWork)
        {
            var param  = GetSearchParams(sortAndFilter, unitOfWork);
            var search = GetSearchEngine(param);

            var searchQuery = search.GetSearchQuery();
            var totalCount  = 0;

            var repo = unitOfWork.GetGenericRepo <TModel>();

            if (sortAndFilter.GetCount)
            {
                totalCount = repo.Get().Count();
            }

            var models = ToViewModel(searchQuery).ToList();

            return(new SearchResults <TViewModel> {
                Results = models, Count = totalCount
            });
        }
Пример #5
0
        protected override void ExecuteCreateMethod(TModel model, IBaseUnitOfWorkEf unitOfWork)
        {
            var repo = unitOfWork.GetGenericRepo <TModel>();

            repo.Insert(model);
        }