protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ApplicationDbContext db = new ApplicationDbContext();

            PostcardSearcher.ClearIndex();
            PostcardSearcher.AddUpdateLuceneIndex(db.Postcards);
            HashTagSearcher.ClearIndex();
            HashTagSearcher.AddUpdateLuceneIndex(db.HashTags);
        }
        public JsonResult SavePostcard(int?templateId, int?categoryId,
                                       string name, string hashTags, string imagePath, string imageUrl, string jsonPath)
        {
            if (templateId == null || categoryId == null || name == null ||
                imageUrl == null || jsonPath == null)
            {
                return(Json(new { success = false }));
            }
            Postcard newPostcard = new Postcard {
                TemplateId = templateId,
                CategoryId = categoryId, Name = name, ImagePath = imagePath,
                ImageUrl   = imageUrl, JsonPath = jsonPath, OwnerId =
                    User.Identity.GetUserId()
            };
            ApplicationDbContext db = new ApplicationDbContext();

            db.Postcards.Add(newPostcard);
            db.SaveChanges();
            PostcardSearcher.AddUpdateLuceneIndex(newPostcard);
            newPostcard.AddHashTags(hashTags);
            return(Json(new { success = true }));
        }