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

            result.Data = newCustomResult;
            return(true);
        }
示例#2
0
        public bool Run(NgTableParams model, ref IQueryable <RelationshipMeta> repository, NgTable <RelationshipMetaViewModel> result, ICoreUser user, IUnitOfWork db)
        {
            var ngTransformer = new QueryToNgTable <RelationshipMetaViewModel>();

            var query = RelationshipMetaMapper.MapDbModelQueryToViewModelQuery(repository);

            ngTransformer.ToNgTableDataSet(model, query, result);
            return(true);
        }
        public bool Run(RelationshipMetaViewModel model, ref IQueryable <RelationshipMeta> repository, IUnitOfWork unitOfWork, Response <RelationshipMetaViewModel> 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 = RelationshipMetaMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <RelationshipMeta>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = RelationshipMetaMapper.MapDbModelToViewModel(updatedDbModel);

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

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

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

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

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

            return(result);
        }