// GET: Reviews/Create
 public async Task<ActionResult> Create()
 {
     var newItem = new Item
     {
         AvailableCategories = await new ItemCategoryHelper().GetAllItemCategories(),
         AssociatedAttributes = await new ItemAttributeHelper().GetBareAttributes()
     };
     return View(newItem);
 }
        public async Task<ActionResult> Create([Bind(Exclude = "CreatedAt,UpdatedAt,Id")] FormCollection collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var attributes = (await new ItemAttributeHelper().GetBareAttributes()).ToList();
                    attributes.ForEach(attr => attr.Value = collection[attr.AttributeId]);
                    var newItem = new Item
                    {
                        AssociatedAttributes = attributes,
                        CategoryId = collection["CategoryId"],
                        Name = collection["Name"],
                        PhotoStream = (Request.Files.Count > 0) ? Request.Files[0]?.InputStream : null,
                        PhotoContentType = (Request.Files.Count > 0) ? Request.Files[0]?.ContentType : null
                    };
                    await new ItemHelper().SaveItem(newItem);
                    return RedirectToAction("Index");
                }

                var placeHolder = new Item
                {
                    AvailableCategories = await new ItemCategoryHelper().GetAllItemCategories(),
                    AssociatedAttributes = await new ItemAttributeHelper().GetBareAttributes()
                };
                return View(placeHolder);
            }
            catch
            {
                var placeHolder = new Item
                {
                    AvailableCategories = await new ItemCategoryHelper().GetAllItemCategories(),
                    AssociatedAttributes = await new ItemAttributeHelper().GetBareAttributes()
                };
                return View(placeHolder);
            }
        }
        public async Task<ActionResult> Edit(string id, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                var attributes = (await new ItemAttributeHelper().GetBareAttributes()).ToList();
                attributes.ForEach(attr =>
                {
                    attr.Value = collection[attr.AttributeId];
                    attr.ItemId = id;
                    attr.Id = collection[attr.AttributeId + attr.ItemId];
                });
                var newItem = new Item
                {
                    Id = id,
                    AssociatedAttributes = attributes,
                    CategoryId = collection["CategoryId"],
                    Name = collection["Name"],
                    PhotoStream = (Request.Files.Count > 0) ? Request.Files[0]?.InputStream : null,
                    PhotoContentType = (Request.Files.Count > 0) ? Request.Files[0]?.ContentType : null
                };
                await new ItemHelper().SaveItem(newItem);
                return RedirectToAction("Index");
            }

            var item = await new ItemHelper().GetItemById(id);
            return View(item);
        }