public void FromEntity_should_map_properties() { var categoryEntity = new Category { Name = "Category 1", Description = "Category 1 Description" }; var category = new EditCategory(); category.FromEntity(categoryEntity); Assert.That(category.Name, Is.EqualTo(categoryEntity.Name)); Assert.That(category.Description, Is.EqualTo(categoryEntity.Description)); }
public ViewResult Edit(Guid id) { var categoryEntity = categoryService.GetSingle(id) ?? new Category(); if (categoryEntity.Id == Guid.Empty) { ModelState.AddModelError("", Localisation.ViewModels.EditCategory.CategoryNotFound); } var category = new EditCategory(); category.FromEntity(categoryEntity); ViewBag.Title = Localisation.Admin.PageContent.Edit; ViewBag.Category = Localisation.Admin.PageContent.Category; return(View(category)); }