public ActionResult AddObligation(ObligationViewModel model)
        {
            if (!ModelState.IsValid) return this.View(model);

            clientProfileManager.SaveObligation(model);

            return Json(true, JsonRequestBehavior.DenyGet);
        }
        public ActionResult AddObligation(int? clientId, int? obligationId)
        {
            int resolvedClientId = this.ResolveClientId(clientId);
            ObligationViewModel model;

            if (obligationId.HasValue)
            {
                model = clientProfileManager.GetObligation(resolvedClientId, obligationId.Value);
            }
            else
            {
                model = new ObligationViewModel { ClientId = resolvedClientId };
            }

            return this.View(model);
        }
Ejemplo n.º 3
0
        private IEnumerable<ObligationViewModel> MapToObligationViewModel(List<Obligation> obligations)
        {
            if (!obligations.Any()) return Enumerable.Empty<ObligationViewModel>();

            var obls = new List<ObligationViewModel>();
            foreach (var obligation in obligations)
            {
                var model = new ObligationViewModel();

                model.CompanyName = obligation.CompanyName;
                model.OutstandingAmount = obligation.OutstandingAmount;
                model.MonthlyPayments = obligation.MontlyPayments ?? default(decimal);
                model.ExpirationDate = obligation.ExpirationDate;
                model.DelayAmount = obligation.DelayAmount;
                model.ObligationId = obligation.Id;

                obls.Add(model);
            }
            return obls;
        }
Ejemplo n.º 4
0
        public void SaveObligation(ObligationViewModel model)
        {
            Obligation obligation;
            if (model.ObligationId != 0)
                obligation = this.clientProfileService.GetClientObligation(model.ObligationId);
            else
                obligation = new Obligation();

            obligation.CompanyName = model.CompanyName;
            obligation.OutstandingAmount = model.OutstandingAmount;
            obligation.MontlyPayments = model.MonthlyPayments;
            obligation.ExpirationDate = model.ExpirationDate ?? DateTime.Now;
            obligation.DelayAmount = model.DelayAmount;

            if (obligation.Id == 0)
            {
                Client client = this.clientProfileService.GetClient(model.ClientId);
                client.Obligations.Add(obligation);
            }

            this.clientProfileService.Save(obligation);
        }
Ejemplo n.º 5
0
        public ObligationViewModel GetObligation(int clientId, int obligationId)
        {
            Obligation obligation = clientProfileService.GetClientObligation(obligationId);

            var model = new ObligationViewModel();

            model.CompanyName = obligation.CompanyName;
            model.OutstandingAmount = obligation.OutstandingAmount;
            model.MonthlyPayments = obligation.MontlyPayments ?? default(decimal);
            model.ExpirationDate = obligation.ExpirationDate;
            model.DelayAmount = obligation.DelayAmount;
            model.ObligationId = obligation.Id;

            return model;
        }