コード例 #1
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);
        }
コード例 #2
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);
        }