public async Task<ActionResult> UpdateNews(UpdateNews newForUpdate)
        {
            var dbHelpre = DBHelper.Instance;
            dbHelpre.BeginTransaction();

            return await Task.Run(() =>
            {
                try
                {
                    bool IsNotValid = false;
                    ViewBag.Message = "Update new news.";
                    if (ModelState.IsValid)
                    {
                        var news = new StateNews
                        {
                            NewsID = newForUpdate.NewsID,
                            Heading = newForUpdate.Heading.Trim(),
                            StateCode = newForUpdate.StateCode,
                            ShortDescription = newForUpdate.ShortDesc.Trim(),
                            NewsDescription = string.IsNullOrEmpty(newForUpdate.Description) ? string.Empty : newForUpdate.Description.Trim(),
                            IsActive = newForUpdate.IsActiveNews ? 1 : 0,
                            IsApproved = newForUpdate.IsApprovedNews ? 1 : 0,
                            IsTopNews = newForUpdate.IsTopTenNews ? 1 : 0,
                            DisplayOrder = 0
                        };

                        var image = new ImageDetail
                        {
                            ImageType = 2,
                            ImageUrl = newForUpdate.ImageUrl,
                            Caption = newForUpdate.Caption,
                            CaptionLink = newForUpdate.CaptionLink,
                            IsActive = 1,
                            IsFirst = 1
                        };

                        var fileName = string.Empty;
                        if (newForUpdate.Image != null && newForUpdate.Image.ContentLength > 0)
                        {
                            fileName = new Random().Next(1000000000).ToString() + Path.GetFileName(newForUpdate.Image.FileName);
                            image.ImageUrl = ImagePath.StateNewsImage + "/" + fileName;
                            image.IsActive = 1;
                            image.IsFirst = 1;
                        }

                        var user = (IUsers)this.Session[Constants.UserSessionKey];
                        StateNewsBL.Instance.UpdateNews(ref dbHelpre, news, image, user);

                        if (!string.IsNullOrEmpty(fileName))
                        {

                            if (SaveImage(ImagePath.StateNewsImage, fileName, newForUpdate.Image))
                            {
                                if (DeleteImage(ImagePath.StateNewsImage, newForUpdate.ImageUrl))
                                {
                                    ViewBag.Message = "Updated successfully.";
                                    ModelState.Clear();
                                }
                                else
                                {
                                    IsNotValid = true;
                                }
                            }
                            else
                            {
                                IsNotValid = true;
                            }
                        }

                        newForUpdate.ImageUrl = image.ImageUrl;

                    }
                    else
                    {
                        IsNotValid = true;
                    }

                    if (IsNotValid)
                    {
                        dbHelpre.RollbackTransaction();
                        ModelState.AddModelError("INSERT", "Oops ! There is some error.");
                        ViewBag.Message = "Oops ! There is some error.";
                    }
                    else
                    {
                        ViewBag.Message = "Updated successfully.";
                        ModelState.Clear();
                    }

                    dbHelpre.CommitTransaction();
                }
                catch (Exception ex)
                {
                    dbHelpre.RollbackTransaction();
                    throw ex;
                }
                finally
                {
                    dbHelpre.ClearAllParameters();
                    dbHelpre.CloseConnection();
                    dbHelpre.Dispose();
                }

                return View(newForUpdate);
            });
        }
        public async Task<ActionResult> UpdateNews(string NewsID)
        {
            return await Task.Run(() =>
            {
                ViewBag.Message = "Update new news.";
                UpdateNews newForUpdate = null;
                var news = StateNewsBL.Instance.Select(NewsID);
                if (news != null)
                {
                    var imgList = ImageDetailBL.Instance.StateNewsImageList(NewsID);
                    IImageDetail image = null;
                    if (imgList != null && imgList.Count() > 0)
                    {
                        image = imgList.FirstOrDefault(v => v.IsActive == 1 && v.IsFirst == 1);
                    }

                    newForUpdate = new UpdateNews
                    {
                        NewsID = news.NewsID,
                        Heading = news.Heading,
                        StateCode = news.StateCode,
                        ShortDesc = news.ShortDescription,
                        Description = news.NewsDescription,
                        Image = null,
                        ImageUrl = " ",
                        Caption = " ",
                        CaptionLink = string.Empty,
                        IsActiveNews = news.IsActive == 1 ? true : false,
                        IsApprovedNews = news.IsApproved == 1 ? true : false,
                        IsTopTenNews = news.IsTopNews == 1 ? true : false

                    };

                    if (image != null)
                    {
                        newForUpdate.ImageUrl = string.IsNullOrEmpty(image.ImageUrl) ? " " : image.ImageUrl;
                        newForUpdate.Caption = news.ImageCaption;
                        newForUpdate.CaptionLink = news.ImageCaptionLink;
                    }
                }
                return View(newForUpdate);
            });
        }