/// <summary>
        /// Indexes the specified model.
        /// </summary>
        /// <param name="id">Visa Id</param>
        /// <param name="mode">Curation Mode</param>
        /// <returns>View</returns>
        public async Task <IActionResult> Manage(int?id, string mode)
        {
            this.ViewBag.Mode = mode;
            BlogPostAddViewModel model = new BlogPostAddViewModel();

            if (mode == "feature")
            {
                model.IsFeatured = true;
            }

            if (mode == "sub")
            {
                model.IsFeatured = false;
            }

            if (id > 0)
            {
                model = this.Mapper.Map <BlogPostAddViewModel>(await this.blogService.GetBlogsByIdAsync(Convert.ToInt32(id)));
            }
            else
            {
                model.Id       = 0;
                model.IsActive = true;
            }

            model.Mode = mode;
            return(this.View(model));
        }
        public IActionResult AddBlogPost(BlogPostAddViewModel formData)
        {
            if (ModelState.IsValid)
            {
                adminBusinessLayer.AddPost(new AddPost
                {
                    Active  = formData.Active,
                    Author  = formData.Author,
                    Content = formData.Content,
                    Title   = formData.Title
                });

                return(RedirectToAction("Home", "Admin"));
            }
            return(View(formData));
        }
        public async Task <IActionResult> Manage(BlogPostAddViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var data = this.Mapper.Map <BlogPostsModel>(model);
                if (model.Id == 0)
                {
                    if (model.ImageFile != null)
                    {
                        model = await this.UploadOnly("Blogs", model);
                    }

                    var record = this.Mapper.Map <BlogPostsModel>(model);
                    record.SetAuditInfo(new Guid(this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value));
                    await this.blogService.InsertAsync(record);

                    this.ShowMessage(Messages.SavedSuccessfully);
                }
                else
                {
                    if (model.ImageFile != null)
                    {
                        model = await this.UploadOnly("Blogs", model);

                        data.Image = model.Image;
                    }

                    data.SetAuditInfo(new Guid(this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value));
                    await this.blogService.UpdateAsync(data);

                    this.ShowMessage(Messages.UpdateSuccessfully);
                }

                return(this.RedirectToAction("index", "blog", new { @mode = model.Mode }));
            }

            return(this.View(model));
        }
        private async Task <BlogPostAddViewModel> UploadOnly(string folder, BlogPostAddViewModel model)
        {
            model.Image = await this.UploadImageBlobStorage(folder, model.ImageFile);

            return(model);
        }