private EntityRecord create_product_entity_record() { var entityRecord = new EntityRecord(_admin.GetEntity<Product>()); var values = new Dictionary<string, object> { { "ProductName", "Test" } }; entityRecord.Fill(values); return entityRecord; }
public void creates_record_and_does_not_create_entity_change_when_is_not_added() { register_default_entities(); var values = new Dictionary<string, object> { { "ProductName", "Product" }, { "Discontinued", false } }; var entityRecord = new EntityRecord(_productEntity); entityRecord.Fill(values); _creator.Create(entityRecord); var products = DB.Products.All().ToList(); Assert.Equal(1, products.Count); A.CallTo(() => _user.CurrentUserName()).MustNotHaveHappened(); var changes = DB.EntityChanges.All().ToList(); Assert.Equal(0, changes.Count); }
public void creates_record_with_one_to_many_foreign_property() { Entity<Category>.Register(); register_default_entities(); var categoryId = DB.Categories.Insert(CategoryName: "Category").CategoryID; var values = new Dictionary<string, object> { { "ProductName", "Product" }, { "Discontinued", false }, { "CategoryID", categoryId } }; var entityRecord = new EntityRecord(_productEntity); entityRecord.Fill(values); _creator.Create(entityRecord); var products = (List<dynamic>)DB.Products.All().ToList(); Assert.Equal(1, products.Count); Assert.Equal(categoryId, products.First().CategoryID); }
public ActionResult Create(string entityName, FormCollection collection) { var entity = _admin.GetEntity(entityName); if (entity == null) { return RedirectToAction("NotFound", new { entityName }); } try { var savedId = _entityService.Create(entity, collection, Request.Files); if (savedId != null) { _notificator.Success(IlaroAdminResources.AddSuccess, entity.Verbose.Singular); return SaveOrUpdateSucceed(entityName, savedId); } } catch (Exception ex) { _log.Error(ex); _notificator.Error(ex.Message); } var entityRecord = new EntityRecord(entity); entityRecord.Fill(collection, Request.Files); var model = new EntityCreateModel { Entity = entity, PropertiesGroups = _entityService.PrepareGroups(entityRecord) }; return View(model); }
public ActionResult Edit(string entityName, string key, FormCollection collection) { var entity = _admin.GetEntity(entityName); if (entity == null) { return RedirectToAction("NotFound", new { entityName }); } try { var isSuccess = _entityService.Edit(entity, key, collection, Request.Files); if (isSuccess) { _notificator.Success(IlaroAdminResources.EditSuccess, entity.Verbose.Singular); return SaveOrUpdateSucceed(entityName, key); } } catch (Exception ex) { _log.Error(ex); _notificator.Error(ex.Message); } var entityRecord = new EntityRecord(entity); entityRecord.Fill(key, collection, Request.Files); var model = new EntityEditModel { Entity = entity, Record = entityRecord, PropertiesGroups = _entityService.PrepareGroups(entityRecord, getKey: false, key: key) }; return View(model); }
internal static EntityRecord CreateEmpty(Entity entity) { var entityRecord = new EntityRecord(entity); entityRecord.Fill(new Dictionary<string, object>()); return entityRecord; }
public void creates_record_with_many_to_one_foreign_property() { register_default_entities(); var productId = DB.Products.Insert(ProductName: "Product").ProductID; var categoryEntity = _admin.GetEntity<Category>(); var entityRecord = new EntityRecord(categoryEntity); entityRecord.Fill(new Dictionary<string, object>()); entityRecord["CategoryName"].Raw = "Category"; entityRecord["Products"].Values.Add(productId); _creator.Create(entityRecord); var categories = (List<dynamic>)DB.Categories.All().ToList(); Assert.Equal(1, categories.Count); var products = (List<dynamic>)DB.Products.All().ToList(); Assert.Equal(1, products.Count); Assert.Equal(categories.First().CategoryID, products.First().CategoryID); }