示例#1
0
        public ActionResult Delete(string debtorName, string debtorAddress, bool isSaved)
        {
            CreateHypothecContractEng contract = new CreateHypothecContractEng();

            if (Session["Debtor"] != null)
            {
                contract.listDebtor = (List <DebtorEng>)Session["Debtor"];
            }
            DebtorEng _debtor = contract.listDebtor.Where(c => c.DebtorName.Equals(debtorName) && c.DebtorAddress.Equals(debtorAddress)).SingleOrDefault();

            contract.listDebtor.Remove(_debtor);
            Session["Debtor"] = contract.listDebtor;
            return(PartialView("_CreateDebtorEng", contract.listDebtor));
        }
        public ActionResult Delete(string hypothecatorName, string hypothecatorNationality, bool isSaved)
        {
            CreateHypothecContractEng contract = new CreateHypothecContractEng();

            if (Session["Hypothecator"] != null)
            {
                contract.listHypothecator = (List <HypothecatorEng>)Session["Hypothecator"];
            }
            List <HypothecatorEng> _hypothector = contract.listHypothecator.Where(c => c.HypothecatorName.Equals(hypothecatorName) && c.HypothecatorNationality.Equals(hypothecatorNationality))
                                                  .ToList();

            if (_hypothector.Count > 0)
            {
                foreach (HypothecatorEng item in _hypothector)
                {
                    contract.listHypothecator.Remove(item);
                }
            }

            Session["Hypothecator"] = contract.listHypothecator;
            return(PartialView("_CreateHypothecatorEng", contract.listHypothecator));
        }
        public ActionResult Add(string HypothecatorName, string HypothecatorSex, DateTime HypothecatorBirthDate, string HypothecatorNationality,
                                string HypothecatorAddress, string HypothecatorVillage, string HypothecatorSangkat, string HypothecatorKhan, string HypothecatorCapital)
        {
            CreateHypothecContractEng contract = new CreateHypothecContractEng();

            if (Session["Hypothecator"] != null)
            {
                contract.listHypothecator = (List <HypothecatorEng>)Session["Hypothecator"];
            }

            if (!String.IsNullOrWhiteSpace(HypothecatorName) && !String.IsNullOrWhiteSpace(HypothecatorNationality))
            {
                if (contract.listHypothecator.Count > 0)
                {
                    int count = contract.listHypothecator.Where(c => c.HypothecatorName.Equals(HypothecatorName) && c.HypothecatorAddress.Equals(HypothecatorAddress)).Count();

                    if (count <= 0)
                    {
                        contract.listHypothecator.Add(new HypothecatorEng
                        {
                            HypothecatorName        = HypothecatorName,
                            HypothecatorSex         = HypothecatorSex,
                            HypothecatorBirthDate   = HypothecatorBirthDate,
                            HypothecatorNationality = HypothecatorNationality,
                            HypothecatorAddress     = HypothecatorAddress,
                            HypothecatorVillage     = HypothecatorVillage,
                            HypothecatorSangkat     = HypothecatorSangkat,
                            HypothecatorKhan        = HypothecatorKhan,
                            HypothecatorCapital     = HypothecatorCapital,
                            isSaved = false
                        });
                    }
                    else
                    {
                        ViewBag.Error = "Hypothecator already have in list. Please input another Hypothecator";
                    }
                }
                else
                {
                    contract.listHypothecator.Add(new HypothecatorEng
                    {
                        HypothecatorName        = HypothecatorName,
                        HypothecatorSex         = HypothecatorSex,
                        HypothecatorBirthDate   = HypothecatorBirthDate,
                        HypothecatorNationality = HypothecatorNationality,
                        HypothecatorAddress     = HypothecatorAddress,
                        HypothecatorVillage     = HypothecatorVillage,
                        HypothecatorSangkat     = HypothecatorSangkat,
                        HypothecatorKhan        = HypothecatorKhan,
                        HypothecatorCapital     = HypothecatorCapital,
                        isSaved = false
                    });
                }
            }
            else
            {
                ViewBag.Error = "Please input information is required.";
            }

            Session["Hypothecator"] = contract.listHypothecator;
            return(PartialView("_CreateHypothecatorEng", contract.listHypothecator));
        }