public void FromEntity_should_map_properties_when_invoked()
        {
            var fakeProduct = Fakes.FakeProduct();
            var editProduct = new EditProduct();

            editProduct.FromEntity(fakeProduct);

            Assert.That(editProduct.Name, Is.EqualTo(fakeProduct.Name));
            Assert.That(editProduct.Description, Is.EqualTo(fakeProduct.Description));
            Assert.That(editProduct.Sku, Is.EqualTo(fakeProduct.Sku));
        }
示例#2
0
        public ViewResult Edit(Guid id)
        {
            var productEntity = productService.GetSingle(id) ?? new Product();

            if (productEntity.Id == Guid.Empty)
            {
                ModelState.AddModelError("", Localisation.ViewModels.EditProduct.ProductNotFound);
            }

            var product = new EditProduct();

            product.FromEntity(productEntity);
            ViewBag.Title    = Localisation.Admin.PageContent.Edit;
            ViewBag.Product  = Localisation.Admin.PageContent.Product;
            ViewBag.ViewType = "Edit";
            return(View(product));
        }
示例#3
0
        public ViewResult DeleteConfirmation(Guid id, int page = 0, int perPage = 25, string orderBy = null, string asc = "true")
        {
            var productEntity = productService.GetSingle(id) ?? new Product();

            if (productEntity.Id == Guid.Empty)
            {
                ModelState.AddModelError("", Localisation.ViewModels.EditProduct.ProductNotFound);
            }

            var product = new EditProduct();

            product.FromEntity(productEntity);
            ViewBag.Title    = Localisation.Admin.PageContent.Delete;
            ViewBag.Product  = Localisation.Admin.PageContent.Product;
            ViewBag.ViewType = "Delete";
            return(View(product));
        }