Exemplo n.º 1
0
        public ProductViewModel(Product product)
        {
            Id = product.Id;
            Name = product.Name;

            if (product.Category != null)
            {
                CategoryId = product.Category.Id;
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(ProductViewModel model)
        {
            var product = new Product();
            var category = Session.Get<Category>(model.CategoryId);

            model.UpdateEntity(product, HttpContext.User.Identity.Name, category);

            Session.Save(product);

            return RedirectToAction("Index");
        }
Exemplo n.º 3
0
 internal void UpdateEntity(Product product, string userName, Category category)
 {
     product.Name = Name;
     product.UserName = userName;
     product.Category = category;
 }