示例#1
0
        public bool Run(RelationshipObjectViewModel model, ref IQueryable <RelationshipObject> repository, IUnitOfWork unitOfWork, Response <RelationshipObjectViewModel> result, ICoreUser user)
        {
            var updatedDbModel  = unitOfWork.With <RelationshipObject>().Single(c => c.Id == model.Id); // Might be a partial class
            var newCustomResult = RelationshipObjectMapper.MapDbModelToViewModel(updatedDbModel);

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

            var query = RelationshipObjectMapper.MapDbModelQueryToViewModelQuery(repository);

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

            unitOfWork.With <RelationshipObject>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = RelationshipObjectMapper.MapDbModelToViewModel(updatedDbModel);

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

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

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

            result.Data = newCustomResult;
            return(true);
        }
示例#5
0
        public Response <RelationshipObjectViewModel> Run(RelationshipObjectViewModel model, ref IQueryable <RelationshipObject> repository, IUnitOfWork unitOfWork, Response <RelationshipObjectViewModel> result, ICoreUser user)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.Id == model.Id);

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

            return(result);
        }