NozzleRepository.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. if (uploadNozzle.type == 1)
  21. {
  22. }
  23. else if (uploadNozzle.type == 2)
  24. {
  25. }
  26. else if (uploadNozzle.type == 3)
  27. {
  28. }
  29. var sds = _fsql.Select<nozzle>().ToList();
  30. return result;
  31. }
  32. public async Task<List<nozzle>> AddNozzle(nozzle _nozzle)
  33. {
  34. return _fsql.Insert(_nozzle).ExecuteInserted();
  35. }
  36. public async Task<tanks> AddTanks(tanks _tanks)
  37. {
  38. try
  39. {
  40. _fsql.Insert(_tanks).ExecuteAffrows();
  41. object insertedIdObj = _fsql.Ado.ExecuteScalar("SELECT LAST_INSERT_ID();");
  42. int insertedId = Convert.ToInt32(insertedIdObj);
  43. // 查询插入后的数据
  44. return _fsql.Select<tanks>().Where(n => n.Id == insertedId).First();
  45. }
  46. catch (Exception ex)
  47. {
  48. }
  49. return null;
  50. }
  51. public async Task<product> AddProduct(product _product)
  52. {
  53. try
  54. {
  55. _fsql.Insert(_product).ExecuteAffrows();
  56. object insertedIdObj = _fsql.Ado.ExecuteScalar("SELECT LAST_INSERT_ID();");
  57. int insertedId = Convert.ToInt32(insertedIdObj);
  58. // 查询插入后的数据
  59. return _fsql.Select<product>().Where(n => n.Id == insertedId).First();
  60. }
  61. catch (Exception ex)
  62. {
  63. }
  64. return null;
  65. }
  66. }
  67. }