public List <DBResponse> InsertLoanBase_t(LoanBase_t loan) { using (var _context = new AccountsEntities()) { string dataList = "[Loan_InsertIntoLoanBase_t] '" + loan.Id + "','" + loan.LoanInformation + "','" + loan.ReferenceNo + "','" + loan.Amount + "','" + loan.Interest + "','" + loan.NetPayable + "'"; var list = _context.Database.SqlQuery <DBResponse>(dataList).ToList <DBResponse>(); return(list); } }
public ActionResult InsertLoanInfo(LoanBase_t loan) { var response = new DBResponse(); try { var job = _dalLoan.InsertLoanBase_t(loan); if (job.Any()) { if (job.FirstOrDefault().Id > 0) { response.Id = job.FirstOrDefault().Id; response.StatusCode = "200"; response.StatusMessage = "Success"; } else { response.Id = -1; response.StatusCode = "501"; response.StatusMessage = job.FirstOrDefault().StatusMessage; } } else { response.StatusCode = "404"; response.StatusMessage = "No available job"; } } catch (Exception ex) { response.Id = -1; response.StatusCode = "500"; response.StatusMessage = ex.Message.ToString(); } var camelCaseFormatter = new JsonSerializerSettings(); camelCaseFormatter.ContractResolver = new CamelCasePropertyNamesContractResolver(); return(Json(JsonConvert.SerializeObject(response, camelCaseFormatter), JsonRequestBehavior.AllowGet)); }