Beispiel #1
0
        public bool Run(AomObjectViewModel model, ref IQueryable <AomObject> repository, IUnitOfWork unitOfWork, Response <AomObjectViewModel> result, ICoreUser user)
        {
            var updatedDbModel  = unitOfWork.With <AomObject>().Single(c => c.Id == model.Id); // Might be a partial class
            var newCustomResult = AomObjectMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
Beispiel #2
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);
        }
        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);
        }
Beispiel #4
0
        public Response <AomObjectViewModel> Run(AomObjectViewModel model, ref IQueryable <AomObject> repository, IUnitOfWork unitOfWork, Response <AomObjectViewModel> result, ICoreUser user)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.Id == model.Id);

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

            return(result);
        }