public bool Run(AomFieldObjectViewModel model, ref IQueryable <AomFieldObject> repository, IUnitOfWork unitOfWork, Response <AomFieldObjectViewModel> 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 = AomFieldObjectMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <AomFieldObject>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = AomFieldObjectMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
        public bool Run(AomFieldObjectViewModel model, IUnitOfWork unitOfWork, Response <AomFieldObjectViewModel> result)
        {
            var dbModel        = unitOfWork.With <AomFieldObject>().Find(model.ID);
            var updatedDbModel = AomFieldObjectMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <AomFieldObject>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = AomFieldObjectMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
예제 #3
0
        public bool Run(AomFieldObjectViewModel model, IUnitOfWork unitOfWork, Response <AomFieldObjectViewModel> result)
        {
            var newCustom = AomFieldObjectMapper.MapInsertModelToDbModel(model);

            unitOfWork.With <AomFieldObject>().Add(newCustom);
            unitOfWork.SaveChanges();
            CreatedId = newCustom.Id;
            var newCustomResult = AomFieldObjectMapper.MapDbModelToViewModel(newCustom);

            result.Data = newCustomResult;
            return(true);
        }