Beispiel #1
0
        public async Task <ActionResult> MakeActive()
        {
            return(await Task.Run(() =>
            {
                var list = new NewsActivationlList();
                list.Message = "Select news and click on submit to make active.";
                list.ActivationlList = new List <NewsActivation>();

                var newsBL = new StateNewsBL();
                var result = newsBL.SelectToActive();
                result.ToList().ForEach(v =>
                {
                    list.ActivationlList.Add(
                        new NewsActivation
                    {
                        Selected = false,
                        TopNewsID = v.NewsID,
                        StateCode = v.StateCode,
                        StateName = v.StateName,
                        ImageUrl = v.ImageUrl,
                        IsActive = v.IsActive,
                        IsTopNews = v.IsTopNews,
                        Heading = v.Heading,
                        DttmCreated = v.DttmCreated
                    });
                });

                return View(list);
            }));
        }
Beispiel #2
0
        public async Task <ActionResult> MakeActive(NewsActivationlList selectedNewsList)
        {
            return(await Task.Run(() =>
            {
                var activeList = new NewsActivationlList();
                activeList.ActivationlList = new List <NewsActivation>();
                var selectedItem = selectedNewsList.ActivationlList.Where(t => t.Selected);

                if (selectedItem.Count() > 0)
                {
                    var list = new List <IStateNews>();
                    selectedItem.ToList().ForEach(item => list.Add(new StateNews()
                    {
                        NewsID = item.TopNewsID,
                        IsActive = item.Selected ? 1 : 0
                    }));

                    var user = (IUsers)this.Session[Constants.UserSessionKey];
                    StateNewsBL.Instance.MakeActiveFor(list, user);

                    StateNewsBL.Instance.SelectToActive().ToList().ForEach(v =>
                    {
                        activeList.ActivationlList.Add(
                            new NewsActivation
                        {
                            Selected = false,
                            TopNewsID = v.NewsID,
                            StateCode = v.StateCode,
                            StateName = v.StateName,
                            IsActive = v.IsActive,
                            IsTopNews = v.IsTopNews,
                            Heading = v.Heading,
                            DttmCreated = v.DttmCreated
                        });
                    });
                    ModelState.Clear();
                    activeList.Message = selectedItem.Count().ToString() + " news has been activeted.";
                }
                else
                {
                    activeList.Message = "Please select atleast one news to approve!";
                }

                return View(activeList);
            }));
        }
Beispiel #3
0
        public ActionResult MakeActive(NewsActivationlList selectedNewsList)
        {
            var activeList = new NewsActivationlList();

            activeList.ActivationlList = new List <NewsActivation>();
            var selectedItem      = selectedNewsList.ActivationlList.Where(t => t.Selected);
            int selectedItemCount = selectedItem.Count();

            if (selectedItemCount > 0)
            {
                var list = new List <ITopNews>();
                selectedItem.ToList().ForEach(item => list.Add(new TopNews()
                {
                    TopNewsID = item.TopNewsID,
                    IsActive  = item.Selected ? 1 : 0
                }));

                var user = (IUsers)this.Session[Constants.UserSessionKey];
                TopNewsBL.Instance.MakeActiveFor(list, user);

                activeList.ActivationlList.Clear();

                TopNewsBL.Instance.SelectTopNewsForActivate().ToList().ForEach(v =>
                {
                    activeList.ActivationlList.Add(
                        new NewsActivation
                    {
                        Selected    = false,
                        TopNewsID   = v.TopNewsID,
                        IsActive    = v.IsActive,
                        Heading     = v.Heading,
                        DttmCreated = v.DttmCreated
                    });
                });
                ModelState.Clear();
                activeList.Message = selectedItemCount.ToString() + " news has been activeted.";
            }
            else
            {
                activeList.Message = "Please select atleast one news to approve!";
            }

            return(View(activeList));
        }