public bool Run(FieldTypesViewModel model, ref IQueryable <FieldType> repository, IUnitOfWork unitOfWork, Response <FieldTypesViewModel> result, ICoreUser user)
        {
            var updatedDbModel  = unitOfWork.With <FieldType>().Single(c => c.Id == model.Id); // Might be a partial class
            var newCustomResult = FieldTypesMapper.MapDbModelToViewModel(updatedDbModel);

            result.Data = newCustomResult;
            return(true);
        }
Exemplo n.º 2
0
        public bool Run(NgTableParams model, ref IQueryable <FieldType> repository, NgTable <FieldTypesViewModel> result, ICoreUser user, IUnitOfWork db)
        {
            var ngTransformer = new QueryToNgTable <FieldTypesViewModel>();

            var query = FieldTypesMapper.MapDbModelQueryToViewModelQuery(repository);

            ngTransformer.ToNgTableDataSet(model, query, result);
            return(true);
        }
Exemplo n.º 3
0
        public bool Run(FieldTypesViewModel model, ref IQueryable <FieldType> repository, IUnitOfWork unitOfWork, Response <FieldTypesViewModel> 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 = FieldTypesMapper.MapInsertModelToDbModel(model, dbModel);

            unitOfWork.With <FieldType>().AddOrUpdate(updatedDbModel);
            unitOfWork.SaveChanges();
            var newCustomResult = FieldTypesMapper.MapDbModelToViewModel(updatedDbModel);

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

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

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

            result.Data = newCustomResult;
            return(true);
        }
Exemplo n.º 5
0
        public Response <FieldTypesViewModel> Run(FieldTypesViewModel model, ref IQueryable <FieldType> repository, IUnitOfWork unitOfWork, Response <FieldTypesViewModel> result, ICoreUser user)
        {
            var itemToUpdate = repository.SingleOrDefault(c => c.Id == model.Id);

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

            return(result);
        }