You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ValuesManager.cs 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Data.Entity;
  2. using iiie.Logs.DBO;
  3. using iiie.WebApiUtils.BusinessManager;
  4. using iiie.WebApiUtils.DBO;
  5. using WebAPiUtils_test.DBO;
  6. namespace WebAPiUtils_test.DataAccess
  7. {
  8. public class ValuesManager : SqlServerManager<T_SqlManager, ValuesDboGet, ValuesDboAdd, ValuesDboEdit, SqlServerManagerEntities, ValuesManager>
  9. {
  10. public override DbSet<T_SqlManager> GetTable(SqlServerManagerEntities db)
  11. {
  12. return db.T_SqlManager;
  13. }
  14. public override ValuesDboGet DbToDboGet(T_SqlManager obj)
  15. {
  16. return new ValuesDboGet
  17. {
  18. Id = obj.id,
  19. MyInt = obj.my_int,
  20. MyString = obj.my_string,
  21. Text = obj.T_Text.text,
  22. TextId = obj.text
  23. };
  24. }
  25. public override OpResult<T_SqlManager> DboAddToDb(ValuesDboAdd obj)
  26. {
  27. var res = GetSingleById(obj.TextId);
  28. if (!res)
  29. return res.To<T_SqlManager>();
  30. return OpResult<T_SqlManager>.Ok(new T_SqlManager
  31. {
  32. my_string = obj.MyString,
  33. my_int = obj.MyInt,
  34. text = obj.TextId
  35. });
  36. }
  37. public override OpResult<T_SqlManager> DboEditToDb(ValuesDboEdit obj, T_SqlManager edit)
  38. {
  39. var res = GetSingleById(obj.TextId);
  40. if (!res)
  41. return res.To<T_SqlManager>();
  42. edit.my_string = obj.MyString;
  43. edit.my_int = obj.MyInt;
  44. edit.text = obj.TextId;
  45. return OpResult<T_SqlManager>.Ok(edit);
  46. }
  47. public static OpResult<DboGetMultiple<ValuesDboGet>> Contains(string text, int page, int perPage)
  48. {
  49. return GetMultiple(x => x.my_string.Contains(text), x => x.id, page, perPage);
  50. }
  51. }
  52. }