Пример #1
0
        public ActionResult SaveLoanInformation(LoanInformation model)
        {
            var serialization = new Serialization();

            var  listingsBA = new Listings();
            long listingID  = 0;

            if (Request.Form["ginfo-hdn"] != null && Request.Form["ginfo-hdn"] != "")
            {
                JavaScriptSerializer js = new JavaScriptSerializer();
                model.GuarantorInformation = js.Deserialize <List <GuarantorInformation> >(Request.Form["ginfo-hdn"]);
            }

            if (model.IsCompany)
            {
                ModelState.Remove("PrimaryBorrowerFirstName");
                ModelState.Remove("LastName");
            }
            else
            {
                ModelState.Remove("CompanyName");
            }
            if (ModelState.IsValid)
            {
                var HashCriteria   = SetHashCriteriaForLoanInformation(model);
                var actualCriteria = serialization.SerializeBinary((object)HashCriteria);
                var result         = listingsBA.SaveLoanInformation(actualCriteria);
                listingID = Convert.ToInt64(serialization.DeSerializeBinary(Convert.ToString(result)));
            }
            else
            {
                LoanInformation loanInformation = new LoanInformation();
                var             result          = listingsBA.GetListingDefaultValuesForLoanInformation();
                loanInformation                      = (LoanInformation)(serialization.DeSerializeBinary(Convert.ToString(result)));
                loanInformation.ListingType          = GetListingLoanType();
                loanInformation.IsGuaranteed         = model.IsGuaranteed;
                loanInformation.GuarantorInformation = model.GuarantorInformation;
                loanInformation.IsCompany            = model.IsCompany;
                //loanInformation.PrimaryBorrowerFirstName = model.PrimaryBorrowerFirstName;
                //loanInformation.LastName = model.LastName;

                return(PartialView("_LoanInformation", loanInformation));
            }
            string ListingID  = CipherTool.EncryptString(Convert.ToString(listingID), true);
            var    jsonResult = new[] {
                new { ListingID = ListingID, ID = listingID },
            };

            return(Json(jsonResult, JsonRequestBehavior.AllowGet));
        }