Exemple #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));
            }
        }
Exemple #2
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));
            }
        }