Example #1
0
        public ActionResult InsertCategoryProperty(FormCollection form)
        {
            using (ShopStorage context = new ShopStorage())
            {
                int categoryId = SystemSettings.CategoryId;
                Category category = context.Categories.Select(c => c).Where(c => c.Id == categoryId).First();
                CategoryProperties categoryProperty = new CategoryProperties();
                categoryProperty.Category = category;
                categoryProperty.Name = form["categoryPropertyName"];
                categoryProperty.Unit = form["categoryUnitName"];

                categoryProperty.IsMainProperty = form["isMainProperty"].ToLowerInvariant().IndexOf("true") > -1;
                context.AddToCategoryProperties(categoryProperty);
                context.SaveChanges();
            }
            return RedirectToAction("CategoryProperties");
        }