Esempio n. 1
0
        public ActionResult Add(ContractView contractView)
        {
            if (ModelState.IsValid)
            {
                IContractsRepository contractsRepository = new ContractsRepository(db);
                Contract             contract            = new Contract();

                contractView.ConvertTo(contractView, contract);

                contractsRepository.Add(contract);
                contractsRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("INSERT", contract.ContractPK);

                if (TempData["legalEntityFK"] != null)
                {
                    return(RedirectToAction("Index", "LegalEntity"));
                }
                else
                {
                    return(RedirectToAction("Index", "Contract"));
                }
            }
            else
            {
                contractView.BindDDLs(contractView, db);

                return(View(contractView));
            }
        }
Esempio n. 2
0
        public ActionResult Add(int?legalEntityFK)
        {
            ContractView contractView = new ContractView();

            if (legalEntityFK != null)
            {
                TempData["legalEntityFK"] = legalEntityFK;

                contractView.LegalEntityFK = (int)legalEntityFK;

                ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);
                contractView.LegalEntityName = legalEntitiesRepository.GetLegalEntityByPK((int)legalEntityFK).Name;
            }

            contractView.BindDDLs(contractView, db);

            return(View(contractView));
        }
Esempio n. 3
0
        public ActionResult Edit(int?contractPK)
        {
            if (contractPK != null)
            {
                IContractsRepository contractsRepository = new ContractsRepository(db);
                Contract             contract            = contractsRepository.GetContractByPK((int)contractPK);
                ContractView         contractView        = new ContractView();

                contractView.ConvertFrom(contract, contractView, db);
                contractView.BindDDLs(contractView, db);

                return(View(contractView));
            }
            else
            {
                return(RedirectToAction("Index", "Contract"));
            }
        }
Esempio n. 4
0
        public ActionResult Edit(ContractView contractView)
        {
            if (ModelState.IsValid)
            {
                IContractsRepository contractsRepository = new ContractsRepository(db);

                Contract contract = contractsRepository.GetContractByPK((int)contractView.ContractPK);
                contractView.ConvertTo(contractView, contract);

                contractsRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", contract.ContractPK);

                return(RedirectToAction("Index", "Contract"));
            }
            else
            {
                contractView.BindDDLs(contractView, db);

                return(View(contractView));
            }
        }