public BsonDocument UpdateShirt(ShirtEditViewModel model)
        {
            var images = new BsonArray(model.sources);

            var filter = new BsonDocument("id", new ObjectId(model.Id));
            var update = Builders<BsonDocument>.Update
                .Set("title", model.title)
                .Set("type", model.series)
                .Set("handle", model.title.ToLower().Replace(' ', '-'))
                .Set("price", model.price)
                .Set("images", images)
                .Set("description", model.description ?? model.series);
            var options = new FindOneAndUpdateOptions<BsonDocument>
            {
                ReturnDocument = ReturnDocument.After
            };
            return collection.FindOneAndUpdateAsync(filter, update, options).Result;
        }
        public ActionResult Edit(ShirtEditViewModel model)
        {
            if (!Authenticated())
            {
                return RedirectToAction("AdminLogin", "Auth");
            }

            var repo = new ShirtRepository();
            var shirtDoc = repo.UpdateShirt(model);
            var shirt = repo.createShirtFromBson(shirtDoc);
            var oldShirt = repo.FindShirtById(shirt.Id.ToString());

            var i = Globals.Shirts.FindIndex(x => x.Id == shirt.Id);
            Globals.Shirts[i] = shirt;

            if (repo.firstShirtOfType(oldShirt.Type) == null)
            {
                Globals.Types.Remove(oldShirt.Type);
                repo.deleteImage(oldShirt.Type);
            }

            return RedirectToAction("Admin", "Auth");
        }