public async Task <IActionResult> EditSliderConfirm(TopSliderViewModel model)
        {
            string nvm;

            try
            {
                if (model != null)
                {
                    var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

                    var _topSlider = dbTopSlider.FindById(model.Id);
                    if (_topSlider != null)
                    {
                        _topSlider.Title              = model.Title;
                        _topSlider.Summery            = model.Summery;
                        _topSlider.Description        = model.Description;
                        _topSlider.AltName            = model.AltName;
                        _topSlider.Link               = model.Link;
                        _topSlider.ScreenResulationId = model.ScreenResulationId > 0 ? model.ScreenResulationId : null;
                        _topSlider.Status             = model.Status;
                        _topSlider.Active             = model.Active;
                        _topSlider.Priotity           = model.Priotity;
                        _topSlider.SetForFuture       = model.SetForFuture;
                        _topSlider.HasButton          = model.HasButton;
                        _topSlider.UserId             = currentUser.Id;

                        if (model.ConnectedCategoryId > 0)
                        {
                            _topSlider.ConnectedCategoryId = model.ConnectedCategoryId;
                        }
                        if (model.ConnectedBrandId > 0)
                        {
                            _topSlider.ConnectedBrandId = model.ConnectedBrandId;
                        }
                        if (model.ConnectedProductId > 0)
                        {
                            _topSlider.ConnectedProductId = model.ConnectedProductId;
                        }
                        if (model.ShowDateTime.ToString().Length > 1 && model.SetForFuture == true)
                        {
                            _topSlider.ShowDateTime = CustomizeCalendar.PersianToGregorian(model.ShowDateTime ?? DateTime.Now);
                        }
                        if (model.ExpireDateTime.ToString().Length > 1 && model.SetForFuture == true)
                        {
                            _topSlider.ExpireDateTime = CustomizeCalendar.PersianToGregorian(model.ExpireDateTime ?? DateTime.Now);
                        }
                        if (model.HasButton && model.ButtonContent != null)
                        {
                            _topSlider.ButtonContent = model.ButtonContent;
                            _topSlider.ButtonLink    = model.ButtonLink;
                        }



                        string folderPath = _configuration.GetSection("DefaultPaths").GetSection("SliderImage").Value;
                        string uploads    = Path.Combine(contentRootPath, folderPath);
                        bool   exists     = System.IO.Directory.Exists(uploads);
                        if (!exists)
                        {
                            System.IO.Directory.CreateDirectory(uploads);
                        }
                        var files = HttpContext.Request.Form.Files;
                        if (files.Count > 0)
                        {
                            FileManager.DeleteFile(contentRootPath, _topSlider.ImagePath);
                        }
                        foreach (var Image in files)
                        {
                            if (Image != null && Image.Length > 0)
                            {
                                var file = Image;

                                if (file.Length > 0)
                                {
                                    var fileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(file.FileName);
                                    using (var fileStream = new FileStream(Path.Combine(uploads, fileName), FileMode.Create))
                                    {
                                        await file.CopyToAsync(fileStream);

                                        _topSlider.ImagePath = folderPath + fileName;
                                    }
                                }
                            }
                        }

                        dbTopSlider.Update(_topSlider); //edit record successfully

                        nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Success_Update, contentRootPath);
                        return(RedirectToAction("ShowSliders", new { notification = nvm }));
                    }
                }
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Update, contentRootPath);
                return(RedirectToAction("ShowSliders", new { notification = nvm }));
            }
            catch (Exception ex)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Operation, contentRootPath);
                return(RedirectToAction("ShowSliders", new { notification = nvm }));
            }
        }
        public async Task <IActionResult> InsertSliderImageConfirm(TopSliderViewModel model)
        {
            string nvm;

            try
            {
                if (!ModelState.IsValid)
                {
                    nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Wrong_Values, contentRootPath);
                    return(RedirectToAction("InsertSliderImage", new { notification = nvm }));
                }
                if (model != null)
                {
                    var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

                    TopSlider TS = new TopSlider()
                    {
                        Title              = model.Title,
                        Summery            = model.Summery,
                        Description        = model.Description,
                        AltName            = model.AltName,
                        Link               = model.Link,
                        ScreenResulationId = model.ScreenResulationId > 0 ? model.ScreenResulationId : null,
                        Status             = model.Status,
                        Active             = model.Active,
                        Priotity           = model.Priotity,
                        SetForFuture       = model.SetForFuture,
                        HasButton          = model.HasButton,
                        UserId             = currentUser.Id
                    };
                    if (model.ConnectedCategoryId > 0)
                    {
                        TS.ConnectedCategoryId = model.ConnectedCategoryId;
                    }
                    if (model.ConnectedBrandId > 0)
                    {
                        TS.ConnectedBrandId = model.ConnectedBrandId;
                    }
                    if (model.ConnectedProductId > 0)
                    {
                        TS.ConnectedProductId = model.ConnectedProductId;
                    }
                    if (model.ShowDateTime.ToString().Length > 1 && model.SetForFuture == true)
                    {
                        TS.ShowDateTime = CustomizeCalendar.PersianToGregorian(model.ShowDateTime ?? DateTime.Now);
                    }
                    if (model.ExpireDateTime.ToString().Length > 1 && model.SetForFuture == true)
                    {
                        TS.ExpireDateTime = CustomizeCalendar.PersianToGregorian(model.ExpireDateTime ?? DateTime.Now);
                    }
                    if (model.HasButton && model.ButtonContent != null)
                    {
                        TS.ButtonContent = model.ButtonContent;
                        TS.ButtonLink    = model.ButtonLink;
                    }

                    string folderPath = _configuration.GetSection("DefaultPaths").GetSection("SliderImage").Value;
                    string uploads    = Path.Combine(contentRootPath, folderPath);
                    bool   exists     = System.IO.Directory.Exists(uploads);
                    if (!exists)
                    {
                        System.IO.Directory.CreateDirectory(uploads);
                    }

                    var files = HttpContext.Request.Form.Files;
                    foreach (var Image in files)
                    {
                        if (Image != null && Image.Length > 0)
                        {
                            var file = Image;

                            if (file.Length > 0)
                            {
                                var fileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(file.FileName);
                                using (var fileStream = new FileStream(Path.Combine(uploads, fileName), FileMode.Create))
                                {
                                    await file.CopyToAsync(fileStream);

                                    TS.ImagePath = folderPath + fileName;
                                }
                            }
                        }
                    }

                    dbTopSlider.Insert(TS); //save record successfully

                    nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Success_Insert, contentRootPath);
                    return(RedirectToAction("InsertSliderImage", new { notification = nvm }));
                }
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Insert, contentRootPath);
                return(RedirectToAction("InsertSliderImage", new { notification = nvm }));
            }
            catch (Exception)
            {
                nvm = NotificationHandler.SerializeMessage <string>(NotificationHandler.Failed_Operation, contentRootPath);
                return(RedirectToAction("InsertSliderImage", new { notification = nvm }));
            }
        }//end InsertSliderImageConfirm