Exemplo n.º 1
0
        public ActionResult DeleteKhmer(string debtorName, string debtorAddress, bool isSaved)
        {
            CreateHypothecContractKhmer contract = new CreateHypothecContractKhmer();

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

            contract.listDebtor.Remove(_debtor);
            Session["DebtorKhmer"] = contract.listDebtor;
            return(PartialView("_CreateDebtorKhmer", contract.listDebtor));
        }
        public ActionResult DeleteKhmer(string hypothecatorName, string hypothecatorNationality, bool isSaved)
        {
            CreateHypothecContractKhmer contract = new CreateHypothecContractKhmer();

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

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

            Session["HypothecatorKhmer"] = contract.listHypothecator;
            return(PartialView("_CreateHypothecatorKhmer", contract.listHypothecator));
        }
        public ActionResult AddKhmer(string HypothecatorName, string HypothecatorSex, DateTime HypothecatorBirthDate, string HypothecatorNationality,
                                     string HypothecatorAddress, string HypothecatorVillage, string HypothecatorSangkat, string HypothecatorKhan, string HypothecatorCapital)
        {
            CreateHypothecContractKhmer contract = new CreateHypothecContractKhmer();

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

            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 HypothecatorKhmer
                        {
                            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 HypothecatorKhmer
                    {
                        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["HypothecatorKhmer"] = contract.listHypothecator;
            return(PartialView("_CreateHypothecatorKhmer", contract.listHypothecator));
        }