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

            result.Data = newCustomResult;
            return(true);
        }
        public bool Run(ContainerToolsViewModel model, ref IQueryable <ContainerTool> repository, IUnitOfWork unitOfWork, Response <ContainerToolsViewModel> 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 = ContainerToolsMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <ContainerTool>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = ContainerToolsMapper.MapDbModelToViewModel(updatedDbModel);

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

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

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

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

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

            return(result);
        }