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);
        }
Exemple #2
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);
        }