public ActionResult AddOffer()
 {
     OfferModel mod = new OfferModel();
     //mod.MaxAnnualSalesAmount = Convert.ToDouble(Session["maxvalue"].ToString());
     //mod.MaxOwnedAmount = Convert.ToDouble(Session["maxvalue"].ToString()) * 2;
     return PartialView("_AddOffer", mod);
 }
        public ActionResult AddOffer(OfferModel model)
        {
            if (ModelState.IsValid)
            {
                SetOfferModifiedFlag(true);

                offerSesssionRepository.AddOffer(model);
                return RedirectToAction("AddOffer");
            }
            return PartialView("_AddOffer", model);
        }
        public void AddOffer(OfferModel offer)
        {
            var data = GetAll();

            if (offer.Id == 0)
            {
                if (data.Count > 0)
                    offer.Id = data.Max(a => a.Id) + 1;
                else
                    offer.Id = 100000;
            }

            data.Add(offer);
            HttpContext.Current.Session[SessionOfferList] = data;
        }
 public void Update(OfferModel offer)
 {
     DelOffer(offer.Id);
     AddOffer(offer);
 }
        public ActionResult Index([Bind(Exclude = "SelectedOffer")] MerchantInformationOfferModel model, string button, long selectedOffer)
        {
            var isComplete = 0;
            if (button == "Complete")
            {
                isComplete = 1;
            }

            //var errorList = new List<string>();
            //foreach (var key in ModelState.Keys)
            //{
            //    ModelState modelState = null;
            //    if (ModelState.TryGetValue(key, out modelState))
            //    {
            //        foreach (var error in modelState.Errors)
            //        {
            //            errorList.Add(
            //                key + "==" + error.ErrorMessage
            //           );
            //        }
            //    }
            //}

            //model.TypeOfPropertyID = 1;
            if (ModelState.IsValid)
            {
                ///Save Data
                // var offers = offerSesssionRepository.GetAll().FirstOrDefault(m => m.IsSelected = true);
                var offers = offerSesssionRepository.GetAll().FirstOrDefault(m => m.offerId == selectedOffer);
                if (offers == null)
                {
                    offers = new OfferModel();
                    model.offers = new List<OfferModel> { offers };
                }

                if (offers.offerexpirationDate < DateTime.Today)
                {
                    ModelState.AddModelError("Expiry", "Offer Expired");
                }
                else
                {
                    if (isComplete == 0)
                    {
                        var apiMethod = string.Format("CreditReport/offers/OfferAcceptance?merchantId={0}&contractId={1}&isCompleted={2}", CurrentMerchantID, ContractID, isComplete);
                        BaseApiData.PostAPIData(apiMethod, offers);
                        base.SetSuccessMessage("Data Updated.");
                    }
                    else
                    {
                        var apiMethod = string.Format("CreditReport/offers/OfferAcceptance?merchantId={0}&contractId={1}&isCompleted={2}", CurrentMerchantID, ContractID, isComplete);
                        BaseApiData.PostAPIData(apiMethod, offers);

                        var savedOffer = merchantApi.GetOfferDetails(CurrentMerchantID, ContractID);
                        var emailSent = false;
                        if (savedOffer.SelectedOffer != null)
                        {
                            emailSent = savedOffer.SelectedOffer.IsEmailSent;
                        }
                        if (emailSent)
                        {

                            string apiData = string.Format("Contracts/OfferAccpContractTask?merchantId={0}&taskTypeId={1}&workflowId={2}&contractId={3}",
                                CurrentMerchantID, (int)TaskTypes.PQOfferAcceptance, 1, ContractID);
                            BaseApiData.GetAPIResult<object>(apiData, () => new object());
                            base.SetSuccessMessage("Offer Acceptance- Task Completed.");
                        }
                        else
                        {
                            base.SetErrorMessage("Can't complete, Please send email first.");
                        }
                    }
                    return RedirectToAction("Index");
                }
            }
            return View(model);
        }
 public ActionResult AddOffer()
 {
     OfferModel mod = new OfferModel();
     return PartialView("_EditOffer", mod);
 }
        public ActionResult UpdateOffer(OfferModel model)
        {
            if (ModelState.IsValid)
            {
                model.ownedAmount = Math.Round(model.loanAmount * model.proportion, 2);
                model.turn = Math.Round(model.ownedAmount / model.monthlypayment, 3);
                offerSesssionRepository.Update(model);
                SetOfferModifiedFlag(true);
                return RedirectToAction("AddOffer");
            }

            return PartialView("_EditOffer", model);
        }