Example #1
0
        private void MakeLoan_Click(object sender, RoutedEventArgs e)
        {
            var     en = EndBox.SelectedDate;
            decimal am;
            decimal p;
            var     now = DateTime.Now;

            if (choCl == null)
            {
                MessageBox.Show("Please choose an account");
            }
            else if (en == null || !decimal.TryParse(amountBox.Text, out am) || !decimal.TryParse(percentBox.Text.Replace(".", ","), out p))
            {
                MessageBox.Show("Invalid input data");
            }
            else if ((en ?? now) < now.AddDays(180))
            {
                MessageBox.Show("Minimum loan period is at least 180 days");
            }
            else
            {
                ILoan lo    = Factory.Instance.GLoan();
                int   accId = choCl.AccId;
                lo.AddLoan(accId, am, en ?? now, p);
                UpdateLoan?.Invoke();
                amountBox.Text           = "30000";
                percentBox.Text          = "8";
                EndBox.SelectedDate      = null;
                clientCombo.SelectedItem = null;
                MessageBox.Show("You've successfully added a new loan");
            }
        }
Example #2
0
        public async Task <IActionResult> AddLoan(LoansDTO loansDTO)
        {
            try
            {
                //var userid = _accessor.HttpContext.User.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).SingleOrDefault();

                var     UserId = "B7C60175-B370-4CE4-AC86-08D81D38F5FE";
                dynamic result = await _loan.AddLoan(loansDTO, UserId);

                if (result.Success == false)
                {
                    return(BadRequest(result));
                }

                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }