Exemplo n.º 1
0
        public ActionResult SingleMergingPost(int?MergingPersonId, int?MainPersonId)
        {
            if (MergingPersonId == 0 || MergingPersonId == null)
            {
                ModelState.AddModelError("", "Please select Merging Person.");
                return(View("SingleMerging"));
            }

            if (MainPersonId == 0 || MainPersonId == null)
            {
                ModelState.AddModelError("", "Please select Main Person.");
                return(View("SingleMerging"));
            }

            if (MergingPersonId == MainPersonId)
            {
                ModelState.AddModelError("", "Merging person and Main person should not be same.");
                return(View("SingleMerging"));
            }



            MergingExcel M = new MergingExcel();

            M.MergingItem = new PersonService(_unitOfWork).Find((int)MergingPersonId).Code;
            M.MainItem    = new PersonService(_unitOfWork).Find((int)MainPersonId).Code;
            //M.MergingItem = new PersonService(_unitOfWork).Find((int)MergingPersonId).Name;
            //M.MainItem = new PersonService(_unitOfWork).Find((int)MainPersonId).Name;

            IList <MergingExcel> MergingRecordList = new List <MergingExcel>();

            MergingRecordList.Add(M);

            return(DatabaseOperation(MergingRecordList));
        }
        public ActionResult SingleMergingPost(int?MergingLedgerAccountId, int?MainLedgerAccountId)
        {
            if (MergingLedgerAccountId == 0 || MergingLedgerAccountId == null)
            {
                ModelState.AddModelError("", "Please select Merging LedgerAccount.");
                return(View("SingleMerging"));
            }

            if (MainLedgerAccountId == 0 || MainLedgerAccountId == null)
            {
                ModelState.AddModelError("", "Please select Main LedgerAccount.");
                return(View("SingleMerging"));
            }

            if (MergingLedgerAccountId == MainLedgerAccountId)
            {
                ModelState.AddModelError("", "Merging LedgerAccount and Main LedgerAccount should not be same.");
                return(View("SingleMerging"));
            }


            LedgerAccount MergingLedgerAccount = new LedgerAccountService(_unitOfWork).Find((int)MergingLedgerAccountId);
            LedgerAccount MainLedgerAccount    = new LedgerAccountService(_unitOfWork).Find((int)MainLedgerAccountId);

            if (MergingLedgerAccount.PersonId != null && MainLedgerAccount.PersonId == null)
            {
                ModelState.AddModelError("", "Merging Ledger Account is a Person Ledger Account and Main Ledger Account is an individual Ledger Account, Can not be merge.");
                return(View("SingleMerging"));
            }

            //if (MergingLedgerAccount.PersonId == null && MainLedgerAccount.PersonId != null)
            //{
            //    ModelState.AddModelError("", "Main Ledger Account is a Person Ledger Account and Merging Ledger Account is an individual Ledger Account, Can not be merge.");
            //    return View("SingleMerging");
            //}


            MergingExcel M = new MergingExcel();

            M.MergingItem = MergingLedgerAccount.LedgerAccountName + MergingLedgerAccount.LedgerAccountSuffix;
            M.MainItem    = MainLedgerAccount.LedgerAccountName + MainLedgerAccount.LedgerAccountSuffix;
            //M.MergingItem = new LedgerAccountService(_unitOfWork).Find((int)MergingLedgerAccountId).Name;
            //M.MainItem = new LedgerAccountService(_unitOfWork).Find((int)MainLedgerAccountId).Name;

            IList <MergingExcel> MergingRecordList = new List <MergingExcel>();

            MergingRecordList.Add(M);

            return(DatabaseOperation(MergingRecordList));
        }