Example #1
0
        public void get_record_with_correct_data_return_record()
        {
            DB.Products.Insert(ProductName: "Product");
            var productId = DB.Products.Insert(ProductName: "Product2").ProductID;

            var enetity = Admin.GetEntity("Product");

            enetity = _source.GetEntityWithData(enetity, productId.ToString()) as Entity;
            Assert.NotNull(enetity);
            Assert.Equal("Product2", enetity["ProductName"].Value.AsString);
        }
        public void updates_record_with_many_to_one_foreign_property()
        {
            var category = DB.Categories.Insert(CategoryName: "Category");
            var product2 = DB.Products.Insert(ProductName: "Product2", CategoryId: category.CategoryID);

            Admin.AddEntity <Category>();
            Admin.SetForeignKeysReferences();
            _entity =
                Admin.EntitiesTypes.FirstOrDefault(x => x.Name == "Category");
            _entity = _source.GetEntityWithData(Admin.GetEntity("Category"), category.CategoryID.ToString());
            _entity["CategoryName"].Value.Raw = "Category";
            _entity["Products"].Value.Values  = new List <object> {
                _productId
            };
            _updater.Update(_entity);

            var categories = (List <dynamic>)DB.Categories.All().ToList();

            Assert.Equal(1, categories.Count);
            var products = (List <dynamic>)DB.Products.All().ToList();

            Assert.Equal(2, products.Count);
            var product = products.First(x => x.ProductID == _productId);

            product2 = products.First(x => x.ProductID == product2.ProductID);
            Assert.Null(product2.CategoryID);
            Assert.Equal(category.CategoryID, product.CategoryID);
        }
        public RecordsUpdater_()
        {
            _source = new RecordsSource(new Notificator());
            _user = A.Fake<IProvidingUser>();
            A.CallTo(() => _user.Current()).Returns("Test");
            var executor = new DbCommandExecutor(_user);
            _updater = new RecordsUpdater(executor, _source);
            Admin.AddEntity<Product>();
            Admin.SetForeignKeysReferences();
            Admin.ConnectionStringName = ConnectionStringName;

            _productId = DB.Products.Insert(ProductName: "Product").ProductID;
            _entity = _source.GetEntityWithData(Admin.GetEntity("Product"), _productId.ToString());
        }
        public RecordsUpdater_()
        {
            _source = new RecordsSource(new Notificator());
            _user   = A.Fake <IProvidingUser>();
            A.CallTo(() => _user.Current()).Returns("Test");
            var executor = new DbCommandExecutor(_user);

            _updater = new RecordsUpdater(executor, _source);
            Admin.AddEntity <Product>();
            Admin.SetForeignKeysReferences();
            Admin.ConnectionStringName = ConnectionStringName;

            _productId = DB.Products.Insert(ProductName: "Product").ProductID;
            _entity    = _source.GetEntityWithData(Admin.GetEntity("Product"), _productId.ToString());
        }
Example #5
0
        public virtual ActionResult Edit(string entityName, string key)
        {
            var entity = _source.GetEntityWithData(entityName, key);

            if (entity == null)
            {
                return(RedirectToAction("Index", "Entities", new { entityName }));
            }

            var model = new EntityEditModel
            {
                Entity           = entity,
                PropertiesGroups = _entityService.PrepareGroups(entity, false, key)
            };

            return(View(model));
        }