public async Task <IActionResult> Create([Bind("Id,Category,Title,Description,Tags")] PolicyViewModel policyVM)
        {
            if (ModelState.IsValid)
            {
                var category = await _context
                               .Categories
                               .SingleOrDefaultAsync(c => c.Title.Equals(policyVM.Category.Title, StringComparison.OrdinalIgnoreCase));

                if (category.IsNotNull())
                {
                    policyVM.Category = category;
                }
                else
                {
                    policyVM.Category = new Category
                    {
                        Title = policyVM.Category.Title,
                        Url   = CustomUrlHelper.URLFriendly(policyVM.Category.Title),
                    };
                }

                var policy = new Policy
                {
                    Category    = policyVM.Category,
                    Description = policyVM.Description,
                    FileUrl     = policyVM.FileUrl,
                    Title       = policyVM.Title,
                    Url         = CustomUrlHelper.URLFriendly(policyVM.Title),
                };

                var file = Request.Form.Files.SingleOrDefault();

                if (file.IsNotNull())
                {
                    var filename = await _fileStorageService.SetBlobAsync(file);

                    policy.FileUrl = filename;
                }

                var tags           = TagHelpers.GetTagsFromString(policyVM.Tags);
                var allTagEntities = GetAllTagEntitiesInternal(policyVM, tags);
                TagHelpers.SetTags <Policy, PolicyTag>(tags, policy, allTagEntities);

                await _context.AddAsync(policy);

                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { Id = policy.Id }));
            }
            ViewData["Categories"] = new SelectList(_context.Categories, nameof(Category.Id), nameof(Category.Title));
            return(View(policyVM));
        }
        public async Task <IActionResult> Create([Bind("Category,Question,Answer,Tags")] FaqViewModel faqVM)
        {
            if (ModelState.IsValid)
            {
                var category = await _context
                               .Categories
                               .SingleOrDefaultAsync(c => c.Title.Equals(faqVM.Category.Title, StringComparison.OrdinalIgnoreCase));

                if (category.IsNotNull())
                {
                    faqVM.Category = category;
                }
                else
                {
                    faqVM.Category = new Category
                    {
                        Title = faqVM.Category.Title,
                        Url   = CustomUrlHelper.URLFriendly(faqVM.Category.Title),
                    };
                }

                var faq = new Faq
                {
                    Answer   = faqVM.Answer,
                    Category = faqVM.Category,
                    Question = faqVM.Question,
                    Url      = CustomUrlHelper.URLFriendly(faqVM.Question),
                };

                var tags           = TagHelpers.GetTagsFromString(faqVM.Tags);
                var allTagEntities = GetAllTagEntitiesInternal(faqVM, tags);
                TagHelpers.SetTags <Faq, FaqTag>(tags, faq, allTagEntities);

                await _context.AddAsync(faq);

                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { Id = faq.Id }));
            }
            ViewData["Categories"] = new SelectList(_context.Categories, nameof(Category.Id), nameof(Category.Title));
            return(View(faqVM));
        }