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

            result.Data = newCustomResult;
            return(true);
        }
        public bool Run(NgTableParams model, ref IQueryable <AomMeta> repository, NgTable <AomMetaViewModel> result, ICoreUser user, IUnitOfWork db)
        {
            var ngTransformer = new QueryToNgTable <AomMetaViewModel>();

            var query = AomMetaMapper.MapDbModelQueryToViewModelQuery(repository);

            ngTransformer.ToNgTableDataSet(model, query, result);
            return(true);
        }
        public bool Run(AomMetaViewModel model, IUnitOfWork unitOfWork, Response <AomMetaViewModel> result)
        {
            var dbModel        = unitOfWork.With <AomMeta>().Find(model.ID);
            var updatedDbModel = AomMetaMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <AomMeta>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = AomMetaMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
示例#4
0
        public bool Run(AomMetaViewModel model, ref IQueryable <AomMeta> repository, IUnitOfWork unitOfWork, Response <AomMetaViewModel> 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 = AomMetaMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <AomMeta>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = AomMetaMapper.MapDbModelToViewModel(updatedDbModel);

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

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

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

            result.Data = newCustomResult;
            return(true);
        }
        public bool Run(AomMetaViewModel model, IUnitOfWork unitOfWork, Response <AomMetaViewModel> result)
        {
            var newCustom = AomMetaMapper.MapInsertModelToDbModel(model);

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

            result.Data = newCustomResult;


            result.Messages.Add(new Message {
                MessageText = "You did it"
            });
            return(true);
        }
示例#7
0
        public Response <AomMetaViewModel> Run(AomMetaViewModel model, IUnitOfWork unitOfWork, Response <AomMetaViewModel> result)
        {
            var itemToUpdate = unitOfWork.With <AomMeta>().SingleOrDefault(c => c.Id == model.ID);

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

            return(result);
        }
        public Response <AomMetaViewModel> Run(AomMetaViewModel model, ref IQueryable <AomMeta> repository, IUnitOfWork unitOfWork, Response <AomMetaViewModel> result, ICoreUser user)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.Id == model.Id);

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

            return(result);
        }