/* * public Payment findPayment(Payment payment) * { * return paymentDao.findPayment(payment); * } * * * public void insertPayment(HttpFileCollectionBase multipartFiles, Payment payment) * { * int masterIdx = sequenceService.getSequenceMasterIdx(); * payment.idx = masterIdx; * String programs = ""; * if(payment.programs.Count!= 0) * { * for (int i= 0; i < payment.programs.Count; i++) * { * if (i == 0) * { * programs = payment.programs[i]; * } * else * * { * programs = programs + "," + payment.programs[i]; * } * } * payment.program = programs; * } * validation(payment); * try { * Mapper.Instance().BeginTransaction(); * paymentDao.insertPayment(payment); * filesService.fileUpload(multipartFiles, "carImg", "jpg|png|gif", 10 * 1024 * 1024, masterIdx, null); * Mapper.Instance().CommitTransaction(); * } * catch (Exception e) * { * Mapper.Instance().RollBackTransaction(); * } * } * * public void updatePayment(HttpFileCollectionBase multipartFiles, Payment payment) * { * String programs = ""; * if (payment.programs.Count != 0) * { * for (int i = 0; i < payment.programs.Count; i++) * { * if (i == 0) * { * programs = payment.programs[i]; * } * else * { * programs = programs + "," + payment.programs[i]; * } * } * payment.program = programs; * } * validation(payment); * try { * Mapper.Instance().BeginTransaction(); * filesService.deleteFileAndFileUpload(multipartFiles, "carImg", "jpg|png|gif", 10 * 1024 * 1024, payment.idx, payment.carIdxs); * this.paymentDao.updatePayment(payment); * Mapper.Instance().CommitTransaction(); * } * catch (Exception e) * { * Mapper.Instance().RollBackTransaction(); * } * } */ public void loadExcelByFileAndUpdateToDB(HttpFileCollectionBase multipartFiles, string regId) { var file = multipartFiles["fileExcel"]; List <Payment> list = this.loadExcelByFile(file); if (list.Count == 0) { return; } try { Mapper.Instance().BeginTransaction(); //Fileupload - update int masterIdx = 900000; filesService.deleteRealFilesAndDataByFileMasterIdx(masterIdx); filesService.fileUpload(multipartFiles, "fileExcel", "xlsx", 5 * 1024 * 1024, masterIdx, null); //Update Db Data paymentDao.deletePaymentAll(); foreach (var payment in list) { payment.regId = regId; paymentDao.insertPayment(payment); } Mapper.Instance().CommitTransaction(); } catch (Exception e) { logger.Debug(e.Message); Mapper.Instance().RollBackTransaction(); } }