示例#1
0
        /// <summary>
        /// passes Disbursement details to repository to save
        /// </summary>
        /// <param name="disbursement"></param>
        /// <returns>number of roles affected</returns>
        public async Task <int> SaveDistursement(DisbursementRequest disbursement)
        {
            var code = await _disbursementRepository.GetCustomerCodeAsync();

            // compute/generate Customer Code
            var cus_Code = code >= 1 ? code + 1 : 1;

            var entity = new Disbursement_Dtl
            {
                Cust_Code   = cus_Code,
                Cust_Name   = disbursement.Cust_Name,
                Disb_Date   = disbursement.Disb_Date,
                Disb_Amount = disbursement.Disb_Amount,
                Int_Rate    = disbursement.Int_Rate,
                Months      = disbursement.Months,
                EMS_St_Date = disbursement.EMS_St_Date
            };

            return(await _disbursementRepository.AddDisbursementAsync(entity));
        }
        /// <summary>
        /// Saves disbursement too database
        /// </summary>
        /// <param name="disbursement"></param>
        /// <returns>number of roles affected</returns>
        public async Task <int> AddDisbursementAsync(Disbursement_Dtl disbursement)
        {
            using (var con = new System.Data.SqlClient.SqlConnection(Cs))
            {
                Cmd.Connection  = con;
                Cmd.CommandType = CommandType.Text;
                Cmd.CommandText = "Insert Into Disbursement_Dtl (Cust_Code, Cust_Name,Disb_Date,Disb_Amount,Int_Rate,Months,EMS_St_Date)" +
                                  "Values(@Cust_Code,@CustomerName,@DisbursementDate,@DisbursementAmount,@InterestRate,@Months,@EMS_St_Date)";

                Cmd.Parameters.AddWithValue("@Cust_Code", disbursement.Cust_Code);
                Cmd.Parameters.AddWithValue("@CustomerName", disbursement.Cust_Name);
                Cmd.Parameters.AddWithValue("@DisbursementDate", disbursement.Disb_Date);
                Cmd.Parameters.AddWithValue("@DisbursementAmount", disbursement.Disb_Amount);
                Cmd.Parameters.AddWithValue("@InterestRate", disbursement.Int_Rate);
                Cmd.Parameters.AddWithValue("@Months", disbursement.Months);
                Cmd.Parameters.AddWithValue("@EMS_St_Date", disbursement.EMS_St_Date);

                await con.OpenAsync();

                return(await Cmd.ExecuteNonQueryAsync());
            }
        }