NozzleRepository.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Fuel.Core.Nozzle.Dto;
  2. using FuelServer.Core.Entity;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace Fuel.Application.Repositories
  9. {
  10. public class NozzleRepository : INozzleRepository
  11. {
  12. private readonly IFreeSql _fsql;
  13. public NozzleRepository(IFreeSql fsql)
  14. {
  15. _fsql = fsql;
  16. }
  17. public async Task<bool> uploadNozzle(UploadNozzle uploadNozzle)
  18. {
  19. bool result = false;
  20. var sds = _fsql.Select<nozzle>().ToList();
  21. return result;
  22. }
  23. public async Task<List<nozzle>> AddNozzle(nozzle _nozzle)
  24. {
  25. return _fsql.Insert(_nozzle).ExecuteInserted();
  26. }
  27. public async Task<tanks> AddTanks(tanks _tanks)
  28. {
  29. try
  30. {
  31. _fsql.Insert(_tanks).ExecuteAffrows();
  32. object insertedIdObj = _fsql.Ado.ExecuteScalar("SELECT LAST_INSERT_ID();");
  33. int insertedId = Convert.ToInt32(insertedIdObj);
  34. // 查询插入后的数据
  35. return _fsql.Select<tanks>().Where(n => n.Id == insertedId).First();
  36. }
  37. catch (Exception ex)
  38. {
  39. }
  40. return null;
  41. }
  42. public async Task<product> AddProduct(product _product)
  43. {
  44. try
  45. {
  46. _fsql.Insert(_product).ExecuteAffrows();
  47. object insertedIdObj = _fsql.Ado.ExecuteScalar("SELECT LAST_INSERT_ID();");
  48. int insertedId = Convert.ToInt32(insertedIdObj);
  49. // 查询插入后的数据
  50. return _fsql.Select<product>().Where(n => n.Id == insertedId).First();
  51. }
  52. catch (Exception ex)
  53. {
  54. }
  55. return null;
  56. }
  57. }
  58. }