public ActionResult Submit(ParaViewModel pModel)
        {
            LawDBEntities objLaw = new LawDBEntities();

            pModel = getUpdatedList(pModel, objLaw);

            if (pModel.paraRightList.Count() > 0)
            {
                foreach (var item in pModel.paraRightList)
                {
                    pModel.ParaSelectedList = (from x in objLaw.tblParas
                                               where x.ParaID == item.Value
                                               select x.ParaText).ToList();
                }


                StringBuilder sb = new StringBuilder();

                foreach (var item in pModel.ParaSelectedList)
                {
                    sb.Append(item);
                    sb.Append('\n');
                }

                pModel.ParaListForTextArea = sb.ToString();
            }



            return(View(pModel));
        }
        public ActionResult ShowPara()
        {
            ParaViewModel paraVM = new ParaViewModel();

            //ParaDAL objDal = new ParaDAL();

            LawDBEntities objLaw = new LawDBEntities();

            //executes the stored proc sp_ProcInitialize
            objLaw.sp_ProcInitialize();

            //Loads the table tblParaLeft into the paraLeftList
            //List<tblParaLeft> paraLeftList = new List<tblParaLeft>();

            paraVM.paraLeftList = objLaw.tblParaLefts
                                  .ToList <tblParaLeft>()
                                  .Select(x => new SelectListItem
            {
                Value = x.ParaID,
                Text  = x.ParaID
            });

            paraVM.paraRightList = objLaw.tblParaRights
                                   .ToList <tblParaRight>()
                                   .Select(x => new SelectListItem
            {
                Value = x.ParaID,
                Text  = x.ParaID
            });


            return(View(paraVM));
        }
        public ActionResult Remove(ParaViewModel pModel)
        {
            LawDBEntities objLaw = new LawDBEntities();

            if (pModel.SelectedParaRightID != null)
            {
                foreach (var item in pModel.SelectedParaRightID.Distinct())
                {
                    objLaw.SP_ProcMove("REMOVE", item);
                }

                objLaw.SaveChanges();
            }

            //calls the method getUpdatedList that Gets the updated RightPara list and LeftPara list from the database
            pModel = getUpdatedList(pModel, objLaw);

            return(View(pModel));
        }
        /// <summary>
        /// Makes DB calls to fetch the updated data from the tables tblParaLeft and tblParaRight
        /// </summary>
        /// <param name="pVM"></param>
        /// <param name="objLaw"></param>
        /// <returns></returns>
        public ParaViewModel getUpdatedList(ParaViewModel pVM, LawDBEntities objLaw)
        {
            pVM.paraLeftList = objLaw.tblParaLefts
                               .ToList <tblParaLeft>()
                               .Select(x => new SelectListItem
            {
                Value = x.ParaID,
                Text  = x.ParaID
            });

            pVM.paraRightList = objLaw.tblParaRights
                                .ToList <tblParaRight>()
                                .Select(x => new SelectListItem
            {
                Value = x.ParaID,
                Text  = x.ParaID
            });

            return(pVM);
        }