예제 #1
0
        public bool Run(AomObjectViewModel model, ref IQueryable <AomObject> repository, IUnitOfWork unitOfWork, Response <AomObjectViewModel> result, ICoreUser user)
        {
            var updatedDbModel  = unitOfWork.With <AomObject>().Single(c => c.Id == model.Id); // Might be a partial class
            var newCustomResult = AomObjectMapper.MapDbModelToViewModel(updatedDbModel);

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

            var query = AomObjectMapper.MapDbModelQueryToViewModelQuery(repository);

            ngTransformer.ToNgTableDataSet(model, query, result);
            return(true);
        }
예제 #3
0
        public bool Run(AomObjectViewModel model, ref IQueryable <AomObject> repository, IUnitOfWork unitOfWork, Response <AomObjectViewModel> 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 = AomObjectMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <AomObject>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = AomObjectMapper.MapDbModelToViewModel(updatedDbModel);

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

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

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

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

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

            return(result);
        }