예제 #1
0
        public ProductViewModel(Product product)
        {
            Id = product.Id;
            Name = product.Name;

            if (product.Category != null)
            {
                CategoryId = product.Category.Id;
            }
        }
예제 #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");
        }
예제 #3
0
 internal void UpdateEntity(Product product, string userName, Category category)
 {
     product.Name = Name;
     product.UserName = userName;
     product.Category = category;
 }