示例#1
0
 public void CreateCategory(string name, List <int> propertisIds)
 {
     using (var dbContextScope = _dbContextScopeFactory.Create())
     {
         var foundCategoryObject = _categoryRepository.GetCategory(name);
         if (foundCategoryObject != null)
         {
             throw new Exception("That category already exists");
         }
         var properties = _propertyControl.GetAllProperties(propertisIds);
         var category   = new Category {
             Name = name, Properties = properties
         };
         _categoryRepository.Create(category);
         dbContextScope.SaveChanges();
     }
 }
 //GET: Admin/AddItem
 //[UserAuthorization(ConnectionPage = "~/Admin/Login", Roles = "Admin")]
 public ActionResult CreateItem()
 {
     ViewBag.CategoryId = new SelectList(_itemCategoryControl.GetAllCategories(), "Id", "Name");
     ViewBag.PropertyId = new SelectList(_propertyControl.GetAllProperties(), "Id", "Name");
     return(View(new Item()
     {
         ItemProperties = _propertyControl.GetAllProperties().Select(x => new ItemProperty {
             Property = x, PropertyId = x.Id
         }).ToList()
     }));
 }