public IActionResult Create(CollectionItem serviceItem) { if (ModelState.IsValid) { _collectionItemService.Create(serviceItem); _collectionItemService.Commit(); return(RedirectToAction("Index")); } ViewBag.Services = new SelectList(_collectionService.GetAll(), "Id", "Name", serviceItem.CollectionId); ViewBag.Icons = new SelectList(_iconService.GetAll(), "Name", "Name", serviceItem.Icon); return(View(serviceItem)); }
public void Create_CreatingCollectionItem_ShouldCreateCollectionItem() { // Arrange var entity = new CollectionItem { Name = "Test" }; var before = _db.CollectionItems.Count(); // Act _service.Create(entity); _service.Commit(); // Assert Assert.Equal(1, _db.CollectionItems.Count() - before); }