예제 #1
0
        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);
        }
예제 #2
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);
        }