Ejemplo n.º 1
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Web,Headquarters,Phone")] Store store)
        {
            if (ModelState.IsValid)
            {
                db.Stores.Add(store);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(store));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,CategoryId")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories.Where(x => x.Children.Count == 0).ToList(), "Id", "Name", "Parent.Name", product.CategoryId);
            return(View(product));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,MeasurementUnit,DataType,CategoryId")] AttributeKey attributeKey)
        {
            if (ModelState.IsValid)
            {
                db.AttributeKeys.Add(attributeKey);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", attributeKey.CategoryId);
            return(View(attributeKey));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,ParentId")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ParentId = new SelectList(db.Categories, "Id", "Name", category.ParentId);
            return(View(category));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> Create([Bind(Include = "ProductId,AttributeKeyId,Value")] AttributeValue attributeValue)
        {
            if (ModelState.IsValid)
            {
                db.Attributes.Add(attributeValue);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.AttributeKeyId = new SelectList(db.AttributeKeys, "Id", "Name", attributeValue.AttributeKeyId);
            ViewBag.ProductId      = new SelectList(db.Products, "Id", "Name", attributeValue.ProductId);
            return(View(attributeValue));
        }
        public async Task <ActionResult> Create([Bind(Include = "ProductId,StoreId,Price")] Inventory inventory)
        {
            var inv = db.Inventories.Find(inventory.ProductId, inventory.StoreId);

            if (ModelState.IsValid && inv == null)
            {
                db.Inventories.Add(inventory);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ProductId = new SelectList(db.Products.OrderBy(x => x.Name), "Id", "Name", "Category.Name", inventory.ProductId);
            ViewBag.StoreId   = new SelectList(db.Stores, "Id", "Name", inventory.StoreId);
            return(View(inventory));
        }