public bool Run(MigrationHistoryViewModel model, ref IQueryable <MigrationHistory> repository, IUnitOfWork unitOfWork, Response <MigrationHistoryViewModel> result, ICoreUser user)
        {
            var updatedDbModel  = unitOfWork.With <MigrationHistory>().Single(c => c.Id == model.Id); // Might be a partial class
            var newCustomResult = MigrationHistoryMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
        public bool Run(NgTableParams model, ref IQueryable <MigrationHistory> repository, NgTable <MigrationHistoryViewModel> result, ICoreUser user, IUnitOfWork db)
        {
            var ngTransformer = new QueryToNgTable <MigrationHistoryViewModel>();

            var query = MigrationHistoryMapper.MapDbModelQueryToViewModelQuery(repository);

            ngTransformer.ToNgTableDataSet(model, query, result);
            return(true);
        }
        public bool Run(MigrationHistoryViewModel model, ref IQueryable <MigrationHistory> repository, IUnitOfWork unitOfWork, Response <MigrationHistoryViewModel> result, ICoreUser user)
        {
            var dbModel        = repository.Single(c => c.Id == model.Id); // you need to be using the primary key could be composit
            var updatedDbModel = MigrationHistoryMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <MigrationHistory>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = MigrationHistoryMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
Beispiel #4
0
        public Guid CreatedId; // Might be a composite key!

        public bool Run(MigrationHistoryViewModel model, IUnitOfWork unitOfWork, Response <MigrationHistoryViewModel> result, ICoreUser user)
        {
            var newCustom = MigrationHistoryMapper.MapInsertModelToDbModel(model);

            unitOfWork.With <MigrationHistory>().Add(newCustom);
            unitOfWork.SaveChanges();
            CreatedId = newCustom.Id;
            model.Id  = CreatedId; // Might be a composit key
            var newCustomResult = MigrationHistoryMapper.MapDbModelToViewModel(newCustom);

            result.Data = newCustomResult;
            return(true);
        }
        public Response <MigrationHistoryViewModel> Run(MigrationHistoryViewModel model, ref IQueryable <MigrationHistory> repository, IUnitOfWork unitOfWork, Response <MigrationHistoryViewModel> result, ICoreUser user)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.Id == model.Id);

            if (itemToUpdate != null)
            {
                var newCustomResult = MigrationHistoryMapper.MapDbModelToViewModel(itemToUpdate);
                result.Data    = newCustomResult;
                result.Success = true;
            }
            else
            {
                result.Success = false;
                result.LogError("Error viewing MigrationHistory");
            }

            return(result);
        }