Ejemplo n.º 1
0
        public bool Run(ToolsViewModel model, ref IQueryable <Tool> repository, IUnitOfWork unitOfWork, Response <ToolsViewModel> result, ICoreUser user)
        {
            var updatedDbModel  = unitOfWork.With <Tool>().Single(c => c.Id == model.Id); // Might be a partial class
            var newCustomResult = ToolsMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
Ejemplo n.º 2
0
        public bool Run(NgTableParams model, ref IQueryable <Tool> repository, NgTable <ToolsViewModel> result, ICoreUser user, IUnitOfWork db)
        {
            var ngTransformer = new QueryToNgTable <ToolsViewModel>();

            var query = ToolsMapper.MapDbModelQueryToViewModelQuery(repository);

            ngTransformer.ToNgTableDataSet(model, query, result);
            return(true);
        }
Ejemplo n.º 3
0
        public bool Run(ToolsViewModel model, ref IQueryable <Tool> repository, IUnitOfWork unitOfWork, Response <ToolsViewModel> 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 = ToolsMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <Tool>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = ToolsMapper.MapDbModelToViewModel(updatedDbModel);

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

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

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

            result.Data = newCustomResult;
            return(true);
        }
Ejemplo n.º 5
0
        public Response <ToolsViewModel> Run(ToolsViewModel model, ref IQueryable <Tool> repository, IUnitOfWork unitOfWork, Response <ToolsViewModel> result, ICoreUser user)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.Id == model.Id);

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

            return(result);
        }