public HttpResponseMessage PostMultiPayment([FromBody] JObject request, int userId) { if (request != null) { var DCarLog = JsonConvert.DeserializeObject <MultiPayment>(request.ToString()); List <prGetIncomeReportDateRangeBusWiseSection_Result> carList = new List <prGetIncomeReportDateRangeBusWiseSection_Result>(); prGetDailyPaymentLog_Result paymentLog = new prGetDailyPaymentLog_Result(); carList = DCarLog.CarList; paymentLog = DCarLog.PaymentLog; User user = _commonService.GetUserById(Convert.ToInt32(userId)); try { using (CarSystemEntities db = new CarSystemEntities()) { string returnData = ""; var carIdList = string.Join(",", carList.Select(x => x.CarLogId)); var balance = db.prCheckAmountValidationForMultiPayment(paymentLog.PaymentAmount, carIdList.ToString(), userId).FirstOrDefault(); if (balance == paymentLog.PaymentAmount) { foreach (prGetIncomeReportDateRangeBusWiseSection_Result car in carList) { var amount = car.TotalIncome - (car.PaymentAmount == null ? 0 : car.PaymentAmount); returnData = db.prSaveMultiPayment(0, car.CarLogId, amount, amount, paymentLog.Notes, paymentLog.PaySlipId, "Paid", paymentLog.ReceivedBy, paymentLog.ReceivedByName, paymentLog.ReceivedDate, paymentLog.Status, Int32.Parse(paymentLog.CreatedBy), paymentLog.Update, paymentLog.PaymentType).FirstOrDefault(); } } else { returnData = user.Language == "bn" ? "আপনার দেওয়া টাকা এবং সিস্টেমের টাকা সমান নয়, অনুগ্রহ করে পর্যালোচনা করে দেখুন।" : "Your amount does not match with system amount, please verify your amount again."; } return(Request.CreateResponse(HttpStatusCode.OK, returnData.ToString())); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "System had filed to save payment information. Please try agian.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Please correct your information and try again.")); } }